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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top