PC Review


Reply
Thread Tools Rate Thread

How to avoid instantiating the class more than 10 times

 
 
Raghuram
Guest
Posts: n/a
 
      19th May 2005
Hi All,

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

Raghuram


 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      19th May 2005
Raghuram <(E-Mail Removed)> wrote:
> 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.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Lloyd Dupont
Guest
Posts: n/a
 
      19th May 2005
1.x version
public sealed MyClass
{
private MyClass() {}
}

2.x version
public static sealed MyClass
{
}


"Raghuram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
> is there any possiablity that we can avoid instantiating the class, if so
> how can we do that. ..
>
> Raghuram
>
>



 
Reply With Quote
 
Saurabh
Guest
Posts: n/a
 
      19th May 2005
What you want is a 'tenton' rather than a 'singletone' shouldn't be much
different than singleton

--Saurabh
"Raghuram" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi All,
>
> is there any possiablity that we can avoid instantiating the class, if so
> how can we do that. ..
>
> Raghuram
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instantiating a Sub Class pbd22 Microsoft C# .NET 5 25th Oct 2009 05:32 PM
How to avoid instantiating the class more than 10 times HarishP Microsoft ASP .NET 2 27th May 2005 12:01 PM
Managed Class Instantiating Unmanaged Class Chris Kiechel Microsoft VC .NET 5 5th Nov 2003 07:58 PM
Instantiating a class in.NET Carl Microsoft ASP .NET 9 6th Aug 2003 06:24 AM
Instantiating a class in .NET Carl Microsoft Dot NET 1 5th Aug 2003 10:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.