What is the VB.NET equivalent of the C# ? operator?
This question already has an answer here:
Historically, IIf
was commonly used for that - but that does not use short-circuiting so is not quite the same. However, there is now a 3-part If
:
hp.pt = If(iniFile.GetValue("System", "PT").ToUpper().Equals("H"), PT.PA, PT.SP)
that does use short-circuiting, and thus is identical to the conditional operator in C#.
您可以使用If运算符
hp.pt = If(iniFile.GetValue("System", "PT").ToUpper().Equals("H"), PT.PA, PT.SP)
尝试使用If
函数,如下所示:
x = If(condition, trueValue, falseValue)
链接地址: http://www.djcxy.com/p/42840.html