return string.IsNullOrEmpty(wb) ? AddressType.InternalAddress : AddressType.ExternalAddress; - The ternary operator is called user2455111
|
3 answers
Alternative form of the if statement:
if (string.IsNullOrEmpty(wb)) { return AddressType.InternalAddress; } else { return AddressType.ExternalAddress; } |
return string.IsNullOrEmpty(wb) ? AddressType.InternalAddress : AddressType.ExternalAddress; If the value of the wb variable is an empty string.Empty (or simply "" ) or null , then AddressType.InternalAddress will be returned, otherwise AddressType.ExternalAddress will be returned.
MSDN Help:
- i.e ? this is if, but: is it else? - olmar102
- @ olmar102, if the condition is met, the result will be the left side of the expression, otherwise the right side. Yes, something like
if...else- Denis Bubnov
|
If the string wb empty or not initialized, return InternalAddress otherwise return ExternalAddress .
MSDN
|