VB.NET Short-hand way to define a variable based on a boolean expression (ternary)
本问题已经有最佳答案,请猛点这里访问。
在C中,我可以这样做:
1 | string outcome = (success?"succeeded":"failed") |
但是在vb.net中,这种语法是唯一等价的操作吗?:
1 2 3 4 5 | If (success) Then outcome ="succeeded" Else outcome ="failed" End If |
1 | outcome = If(success,"succeeded","failed") |