-1

IIF seems to be unavailable in .net 4, do we have a replacement?

IIf(condition = 0, True, False)

Would be a simple if statement a good replacement?

wookiee
  • 110
  • 1
  • 3
  • 11
  • You spelled "[IF](https://msdn.microsoft.com/en-us/library/bb513985.aspx)" wrong. – Justin Ryan Jun 17 '15 at 09:36
  • that is not the question – wookiee Jun 17 '15 at 09:53
  • 2
    Then what is your question? I gave you a link to information about vb.net's ternary operator. The only thing left is good ol' `If (True) Than (this) Else (this) End If`. [Maybe this will clarify.](http://stackoverflow.com/a/28452/242584) – Justin Ryan Jun 17 '15 at 10:01
  • `Dim isTrue As Boolean = (condition = 0)` should suffice for your example – Ric Jun 17 '15 at 10:54
  • "IIF seems to be unavailable " really? https://msdn.microsoft.com/es-es/library/microsoft.visualbasic.interaction.iif(v=vs.110).aspx What error do you have using it? – Morcilla de Arroz Jun 17 '15 at 11:16
  • What makes you think it is unavailable? Its part of the `VisualBasic` Namespace - they did not remove it from NET 4.0, but you dont need it anyway, the If Operator works better – Ňɏssa Pøngjǣrdenlarp Jun 17 '15 at 12:15
  • you are all right, i don't know what the problem was, i restarted the visual studio and after a rebuild it all worked fine – wookiee Jun 18 '15 at 10:19

1 Answers1

0

In the second? example here(VS2015RC) Microsoft is using IIF to illustrate how the If operator is short circuited, so I think IIF is still with us.

dbasnett
  • 11,334
  • 2
  • 25
  • 33