I have the following statement:
serverCard.Details = !String.IsNullOrEmpty(card.Details) ? card.Details : serverCard.Details;
I want to check and see if card.Details is null or empty... if not, write the value. Is there any syntax that allows me to leave out the else conditional?
What does 'expand and simplify' mean? In order to expand and simplify an expression, we need to multiply out the brackets and then simplify the resulting expression by collecting the like terms. Expanding brackets (or multiplying out) is the process by which we remove brackets.
Sure, just use a regular if
:
if(!String.IsNullOrEmpty(card.Details))
serverCard.Details = card.Details
You can always use the old if
statement:
if(!String.IsNullOrEmpty(card.Details))
{
serverCard.Details = card.Details;
}
I think the ternary operator is not needed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With