Null-coalescing operator and operator && in C#
- by abatishchev
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 any is null then this.Any.HasValue return false
if any has value, then it returns value considering another boolean property, i.e. Any && SomeBool