小编典典

是否有 C# 的 '??' 的 VB.NET 等价物 操作员?

all

C# 的运算符是否有 VB.NET 等价物??


阅读 66

收藏
2022-07-16

共1个答案

小编典典

使用If()带有两个参数的运算符(Microsoft 文档):

' Variable first is a nullable type.
Dim first? As Integer = 3
Dim second As Integer = 6

' Variable first <> Nothing, so its value, 3, is returned.
Console.WriteLine(If(first, second))

second = Nothing
' Variable first <> Nothing, so the value of first is returned again. 
Console.WriteLine(If(first, second))

first = Nothing second = 6
' Variable first = Nothing, so 6 is returned.
Console.WriteLine(If(first, second))
2022-07-16