Coalesce ?? operator in C# 2.0

Jan 14
2008 21:18 (ASP.NET, Development) · Русский (3,590 views)

Operator ??, that was introduced in the .NET 2.0, takes first place in my top used C# idioms list a long time, but unfortunately it is rarely used in projects I’ve participated. Therefore these snippets could be found in production code very often:

public string Caption
{
    get { return ViewState["Caption"] != null ? (string) ViewState["Caption"] : ""; }
    set { ViewState["Caption"] = value; }
}

Read the rest of entry »

 
Copyright © 2005 - 2008, Dmytro Shteflyuk