Confusion regarding C# property
<p>i got a sample code from a site. one thing i just do not understand regarding how value is added in <code>ViewState</code> automatically.</p>

<p>the code as follows</p>

<pre><code>private Dictionary&lt;Guid, string&gt; Names
{
    get { return (Dictionary&lt;Guid, string&gt;)ViewState["Names"]; }
    set { ViewState["Names"] = value; }
}

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        // to keep this sample really simple, we will populate some
        // sample data in a Dictionary and store in the viewstate
        var names = new Dictionary&lt;Guid, string&gt;
        {
            { Guid.NewGuid(), "John" },
            { Guid.NewGuid(), "Smith" },
            { Guid.NewGuid(), "Arther" },
            { Guid.NewGuid(), "Hari" }
        };
        //store the list in the viewstate.
        ViewState.Add("Names", names);

        //init grid           
    }
}

protected void btnAddSave_Click(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        Names.Add(Guid.NewGuid(), txtNewName.Text);            
    }
}
</code></pre>

<p>in page load event i understand that few values has been added in Dictionary collection and after that the whole collection is added in ViewState named "Names".</p>

<p>in <code>btnAddSave_Click</code> event the code <code>Names.Add(Guid.NewGuid(), txtNewName.Text);</code> adds name again in collection. </p>

<p>but one things i just do not understand that how new value is added in viewstate. </p>

<p>if someone look <code>private Dictionary&lt;Guid, string&gt; Names</code> property there is no any setter so how automatically new value is added in ViewState . i hope my question is clear. in simple word i just want to know there no any setter but then how new values has been added in ViewState when the code goes like <code>Names.Add(Guid.NewGuid(), txtNewName.Text);</code>. </p>

<p>automatically how new values has been added in ViewState . because new values is added in dictionary collection but there is no code available where all dictionary values added in ViewState after adding any value to the dictionary collection.i run the code and it works fine.so this code become very ambiguous for me. so please help me to understand how new values is added in ViewState when any new values is added in dictionary collection. Thanks!</p>
