Quantcast
Channel: FlexiCoder Blog » .Net code
Viewing all articles
Browse latest Browse all 10

?? Operator (C# Reference)

$
0
0

This operator allows you to supply an alternative value if the value being supplied is null. It only works on nullable datatypes but with a bit of googling came accross this article.

public int CurrentPage
{
    get
    {
        return (int)(ViewState["_CurrentPage"] ?? 0);
    }
    set
    {
        this.ViewState["_CurrentPage"] = value;
    }
}

The offical Microsoft article


Viewing all articles
Browse latest Browse all 10

Trending Articles