Store TotalCount in ViewState Is there a more concise way of doing this?

const string TOTAL_COUNT_KEY = "totalCount";
private int TotalCount
{
    get
    {
        int safeInt = 0;
        if (ViewState[TOTAL_COUNT_KEY] != null)
            safeInt = (int)ViewState[TOTAL_COUNT_KEY];
        return safeInt;
    }
    set { ViewState[TOTAL_COUNT_KEY] = value; }
}
You can use the ? operator :

const string TOTAL_COUNT_KEY = "totalCount";
private int TotalCount
{
    get
    {
        return ViewState[TOTAL_COUNT_KEY] != null ? (int)ViewState[TOTAL_COUNT_KEY] : 0;
    }
    set { ViewState[TOTAL_COUNT_KEY] = value; }
}


You can use the null propagation operator ?.

const string TOTAL_COUNT_KEY = "totalCount";
private int TotalCount
{
    get
    {
        return ((int?)ViewState[TOTAL_COUNT_KEY])?.Value ?? 0;
    }
    set { ViewState[TOTAL_COUNT_KEY] = value; }
}


It works this way: 


We cast the ViewState[TOTAL_COUNT_KEY] to int?, 
This way, it is either null or the value (let's say 42). 
Then, the ?. operator will return null if the viewstate property is null, otherwise it'll return the value, 42.
If it is null, the ?? operator will return 0.


I think the ? operator is the clearest, the second one is a little more ninja and might not be appropriate if some member of your team (if you have one) don't fully understand the operators.