How to avoid instantiating the class more than 10 times

  • Thread starter Thread starter Raghuram
  • Start date Start date
R

Raghuram

Hi All,

is there any possiablity that we can avoid instantiating the class, if so
how can we do that. ..

Raghuram
 
Raghuram said:
is there any possiablity that we can avoid instantiating the class, if so
how can we do that. ..

Well, what do you want to happen once you've created ten instances and
someone tries to create an eleventh? You could throw an exception, or
you could keep a pool of previous instances, for example.
 
1.x version
public sealed MyClass
{
private MyClass() {}
}

2.x version
public static sealed MyClass
{
}
 
What you want is a 'tenton' rather than a 'singletone' shouldn't be much
different than singleton

--Saurabh
 
Back
Top