c# is null or empty code example
Example 1: c# check if string is empty
if (string.IsNullOrEmpty(myString)) {
}
Example 2: c# check that value is not null or 0
public static bool IsNullOrValue(this double? value, double valueToCheck)
{
return (value??valueToCheck) == valueToCheck;
}
Example 3: if property is null then c#
The null-conditional operators are short-circuiting.
That is, if one operation in a chain of conditional member or element
access operations returns null, the rest of the chain doesn't execute.
In the following example, B is not evaluated if A evaluates to null
and C is not evaluated if A or B evaluates to null:
CODE
------------------
A?.B?.Do(C);
A?.B?[C];