Syntax to access variables in viewstate
<p>I want to retain a variable between postbacks, so I write an accessor to put it into viewstate. Which one of these is the best way to access it? Or is there a better option?</p>

<p>Option 1:</p>

<pre><code>private int Status
{
    get
    {
     try
     {
      return (int)ViewState[@"__Status"];
     }
     catch
     {
      return 0;
     }
    }
    set
    {
        ViewState[@"__Status"] = value;
    }
}
</code></pre>

<p>Option 2:</p>

<pre><code>private int Status
{
    get
    {
        if (ViewState[@"__Status"] is int)
        {
            return (int)ViewState[@"__Status"];
        }
        else
        {
            return 0;
        }
    }
    set
    {
        ViewState[@"__Status"] = value;
    }
}
</code></pre>

<p>Thanks</p>

<p>Edit: I'm using C# 2.0</p>
