Quantcast
Channel: Nullable and IIf
Browsing all 9 articles
Browse latest View live

Nullable and IIf

I was only declaring o as object in my test because, if an explicit type was required and If was returning Object, I expected it to say "Type of o is System.Object".Because it didn't say that, I...

View Article



Nullable and IIf

Because you are explicitly stating that your "o" variable is an object, you have to be explicit in the typing from the If ternary operator. If you want to use type inference, you need to specify the...

View Article

Nullable and IIf

I suppose as long as you are dealing with similar types, you would not need to cast.Only in scenarios where the 2 types can not be implicitly interchanged, or one can not be widened to the other type...

View Article

Nullable and IIf

With regard to casting the If result, I notice that if VS cannot infer a common type for the 2nd and 3rd arguments, I get a blue squiggly error:Error 1 Cannot infer a common type for the second and...

View Article

Nullable and IIf

Yes you would need to cast to the desired type using the If operator, same as IIF function. This is because the true and false parts it could possibly return, are of type object, since it doesn't know...

View Article


Nullable and IIf

Ah thanks a lot. Did not know about ternary If. Question: In the documentation for the IIF function, there is a warning that the returned object needs to be cast if Option Strict is on. Is that the...

View Article

Nullable and IIf

'IIf' is a function and all calls to this function will have all arguments evaluated upon calling the function - this is true for all function calls, not just 'IIf'.In VB9, you can use the new ternary...

View Article

Nullable and IIf

Workaround:In reality waa is a Nullable(Of Double) and I wanted to use ToString("r") to ensure roundtrip. This seems to work:<waa><%= String.Format("{0:r}", waa) %></waa> 

View Article


Nullable and IIf

If waa is a Nullable(of Integer), why doesn't this work when waa is null?Iif(waa.HasValue, waa.Value.ToString(), "") I get an error "Nullable object must have a value."Don't tell me Iif is evaluating...

View Article

Browsing all 9 articles
Browse latest View live




Latest Images