i’m afraid that this is a stupid question, but i must assume that i have programmed VB.Net too long and now can’t figure out how to convert this C# null coalescing operator into VB.Net:
if( Convert.ToBoolean(ViewState[tp.UniqueID + "_Display"] ?? true) == false ){}
I know the IIF-Function but i’m not sure how to use it here and if it gives the correct result(in IIF both expressions are being evaluated). Please help to shed light on the dark.
EDIT: if you want to see the source of this: forums.asp.net
There you can see a solution that generates a Option Strict On disallows implicit conversions from 'Object' to 'Boolean' compiler exception.
You want the If operator (Not the IIF function). It can be used as the equivalent of both the
?:conditional operator and the??null coalescing operator from C#, depending on whether it’s passed 3 arguments or 2You really want something like:
Which at least still gives you short-circuiting.