title: c# How to get the original object of list element Not references
body: <p>I have two classes: <code>ClassA</code> and <code>Test</code></p>
  
  <ol>
  <li>I want to set <code>Test.classA = null</code> by <code>ClassA.Clean()</code>.</li>
  <li>I dont want use <code>Test.classA</code> directly</li>
  </ol>
  
  <p>The code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ClassA 
  {
      private static List &lt; ClassA &gt; list = new List &lt; ClassA &gt; ();
      public ClassA() 
      {
          list.Add(this);
      }
      public static void Clean() 
      {
          for (var i = 0; i &lt; list.Count; i++) 
          {
              //var classA = list[i];
              //classA = null;
          }
      }
  }
  public class Test 
  {
      private static ClassA classA;
      void DoSomething() 
      {
          if (classA == null)
              classA = new ClassA();
      }
  }
  </code></pre>