有没有可能在VB.NET的IF条件中为变量赋值?
像这样的东西:
Dim customer As Customer = Nothing
If IsNothing(customer = GetCustomer(id)) Then
Return False
End If
谢谢
最佳答案
抱歉,没有。另一方面,它会变得非常困惑,因为 VB.NET 使用相同的运算符进行赋值和相等。
If a = b Then 'wait, is this an assignment or comparison?!
相反,只需设置变量并进行比较:
Dim customer As Customer = Nothing
customer = GetCustomer(id)
If IsNothing(customer) Then
Return False
End If
关于VB.NET:在IF条件内为变量赋值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3350433/