VB.NET基于布尔表达式(三元)定义变量的简便方法

时间:2018-04-13 15:09:23

标签: vb.net ternary

在C#中,我可以这样做:

string outcome = (success?"succeeded":"failed")

但是在VB.NET中这种语法是唯一的等效操作吗?:

If (success) Then
    outcome = "succeeded"
Else
    outcome = "failed"
End If

1 个答案:

答案 0 :(得分:2)

outcome = If(success,"succeeded","failed")