artmsft - ramdom programming tips
Wednesday, February 23, 2011
C# - Short cut for "If the value is null, assign the following value instead"
string errorMessage = obj.Message ?? "N/A";
Equals:
string errorMessage;
if (obj.Message == null)
{
errorMessage = "N/A";
}
else
{
errorMessage = obj.Message;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment