Is there a conditional ternary operator in VB.NET?

前端 未结 3 588
北海茫月
北海茫月 2020-11-22 11:31

In Perl (and other languages) a conditional ternary operator can be expressed like this:

my $foo = $bar == $buz ? $cat : $dog;

Is there a s

3条回答
  •  一向
    一向 (楼主)
    2020-11-22 11:53

    iif has always been available in VB, even in VB6.

    Dim foo as String = iif(bar = buz, cat, dog)
    

    It is not a true operator, as such, but a function in the Microsoft.VisualBasic namespace.

提交回复
热议问题