Instead of operator 'if ' and '?' sometimes we can use operator '??'
code with operator 'if'
code with operator '?'
string getName_with_operator_question(string name)
{
return (name == null) ? "default" : name;
}
code with operator '??'
string getName_with_operator_double_question(string name)
{
return name ?? "default";
}
Sample can be download:
Additional Links:
No comments:
Post a Comment