title: How can I see all instances of a class?
body: <p>I have a short presentation at school for relations between classes (UML), and I want to show with code how composition and aggregation work in practical use and the difference between them. In order to do that however I want to be able to be able to see all active objects atm, to proove that the object I deleted and the object that was part of it are truly gone now.</p>
  
  <p>This is a quick example of what I am trying to do:</p>
  
  
  
  <pre><code>List&lt;Company&gt;companies = new List&lt;Company&gt;(){ 
      new Company(){ 
        Name = "Greiner", 
        new Boss(){
          Name = "Hugo",
        },
     }, 
  };
  
  Company comp = companies.FirstOrDefault();
  companies.Remove(comp);
  </code></pre>
  
  <p>Now I want to somehow show that the Boss is gone along with the company, not just the (indirect) reference to him. So I thought of looking at all active objects.</p>
  
  <p>Is there any way to do this? I am aware that the garbage collector is supposed to do this, but I dont want to tell my fellow students to just believe my words.</p>
  
  <p>Also I do tend to think overly complicated, so my approach might be completely backwards, so any suggestions how to proove the differences between aggregation and composition are welcome.</p>
  
  <p>Regards</p>
  
  <p>Andreas Postolache</p>