title: Limit instances creation of a class?
body: <p>I am using C#. I have created a class which can be included in any c#.net project (desktop or web based), but I want that only 10 objects will be created in that application of my class. If object instances created more than 10 then it should give an error or simple will not work.</p>
  
  <p>There can be two situations, </p>
  
  <ol>
  <li>I'll included myclass.cs file in any
  project or </li>
  <li>I'll bundle my class in a DLL and then include it in any application</li>
  </ol>
  
  <p>In both situations it must through error if more than 10 instances of my class is created in the application.</p>
  
  <p>This question was asked by my teacher, he told me to search for the answer on internet, I tried but no where found any solution for this problem, I haven't heard that we can limit objects?</p>
  
  <p>Is it possible, if yes then how?</p>
  
  <p>Thanks</p>