Is it possible to use together any way operator ?? and operator && in next case:
bool? Any
{
get
{
var any = this.ViewState["any"] as bool?;
return any.HasValue ? any.Value && this.SomeBool : any;
}
}
This means next:
- if
anyis null thenthis.Any.HasValuereturnfalse - if
anyhas value, then it returns value considering another boolean property, i.e.Any && SomeBool
I’m wondering why nobody has suggested this so far:
This returns
nullifanyis null, no matter what the value ofthis.SomeBoolis;trueif bothanyandthis.SomeBoolare true; andfalseifanyis not null, andthis.SomeBoolis false.