title: What is a good design pattern in C# for classes that need to reference other classes?
body: <p>I am working on a business problem in C#.NET.  I have two classes, named C and W that will be instantiated independently at different times.</p>
  
  <p>An object of class C needs to contain references to 0 ... n objects of class W, i.e. a C object can contain up to n W objects.</p>
  
  <p>Each W object needs to contain a reference to exactly 1 object of class C, i.e. a W object is contained in one C object.</p>
  
  <p>An object of class C is usually instantiated first.  At a later point, its W contents are discovered, and instantiated.  At this later point, I need to cross reference the C and W objects to each other.</p>
  
  <p>What is a good design pattern for this?  I actually have cases where I have three or four classes involved but we can talk about two classes to keep it simple.</p>
  
  <p>I was thinking of something simple like:</p>
  
  <pre><code>class C
  {
     public List&lt;W&gt; contentsW;
  
  }
  
  class W
  {
    public C containerC;
  
  }
  </code></pre>
  
  <p>This will work for the moment but I can foresee having to write a fair amount of code to keep track of all the references and their validity.  I'd like to implement code down the road to do shallow refreshes of just the container and deep refreshes of all referenced classes.  Are there any other approaches and what are their advantages?</p>
  
  <p>Edit on 11/3:
  Thanks to all for the good answers and good discussion.  I finally chose jop's answer because that came closest to what I wanted to do, but the other answers also helped.  Thanks again!</p>