VB.NET 基于布尔表达式(三元)定义变量的简写方式
VB.NET Short-hand way to define a variable based on a boolean expression (ternary)
在 C# 中我可以这样做:
string outcome = (success?"succeeded":"failed")
但是在VB.NET中这个语法是唯一的等效操作吗?:
If (success) Then
outcome = "succeeded"
Else
outcome = "failed"
End If
outcome = If(success,"succeeded","failed")
在 C# 中我可以这样做:
string outcome = (success?"succeeded":"failed")
但是在VB.NET中这个语法是唯一的等效操作吗?:
If (success) Then
outcome = "succeeded"
Else
outcome = "failed"
End If
outcome = If(success,"succeeded","failed")