How you can limit a class to create only two instances ? #AspNetInterviewQuestionsSeries
How you can limit a class to create only two(n) instances ?
This is one of my favorite question in an interview.So before watching the answer take a minute and think how you can create a such class .. tough ? Ahan its very easy.
Answer : The basic idea is create a static property and increment that in constructor every time you are creating an object of that class. And throw an exception when that count is greater than two.
next question which can be ask is :

