Assign object by reference
<p>I have two viewState properties. </p>

<p>One is a <code>List&lt;MyObject&gt; MyObjects</code><br>
And another one is <code>MyObject SelectedObject</code>  </p>

<p>Whenever user selects an object from the list, I assign it to SelectedObject like this:  </p>

<pre><code>SelectedObject = MyObjects.Where(x=&gt;x.MyId ==IdSelectedInUI)  
</code></pre>

<p>This allows me easy manipulation of the <code>SelectedObject</code>.<br>
Now, When I change <code>SelectedObject</code>'s properties, how Can I assign those properties back to the original object in the list? I was thinking to use <code>ref</code>, but cannot quite figure it out.  </p>

<p><strong>Edit</strong> 
All of the objects are classes, not structs.<br>
So, here's what I have:  </p>

<pre><code>//Children are of type =List&lt;MyParentObject.ChildObject&gt;
 public MyParentObject MyParent
        {
            get
            {
                if (ViewState["MyParent"] == null)
                {
                    MyParent= GetItemsFromDatabase();
                }
                return (TaskInfo)ViewState["MyParent"];
            }

            set
            {
                ViewState["MyParent"] = value;
            }
        }

        public MyParentObject.ChildObject SelectedChild
        {
            get
            {
                return (MyParentObject.ChildObject)ViewState["Child"];
            }

            set
            {
                ViewState["Child"] = value;
            }
        }  
        protected onButtonClick()
        {
          SelectedChild =  MyParent.Children.Where(x=&gt;x.Child_Id == Convert.ToInt32(txt.Text)).FirstOrDefault();
         SelectedChild.Property2 = "test2" //OldValue "test1"
         //now if I run 
        MyParent.Children.Where(x=&gt;x.Child_Id ==Convert.ToInt32(txt.Text)).Select(x=&gt;x.Property2) //Shows "test1" and I expect "test2"
        }
        }
</code></pre>
