Null-coalescing operator and operator && in C#
Posted
by abatishchev
on Stack Overflow
See other posts from Stack Overflow
or by abatishchev
Published on 2010-04-27T22:20:03Z
Indexed on
2010/04/27
22:23 UTC
Read the original article
Hit count: 518
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 thenthis.Any.HasValue
returnfalse
- if
any
has value, then it returns value considering another boolean property, i.e.Any && SomeBool
© Stack Overflow or respective owner