What is the VB.NET equivalent of the C# ? operator?

This question already has an answer here:

  • Is there a conditional ternary operator in VB.NET? 8 answers

  • 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

    上一篇: 在vb.net中使用c#condtional运算符

    下一篇: 什么是C#的VB.NET等价物? 运营商?