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; }
}
{
get { return ViewState["Caption"] != null ? (string) ViewState["Caption"] : ""; }
set { ViewState["Caption"] = value; }
}
Русский
English