Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to implement singelton in C# & its uses?



how to implement singelton in C# & its uses?..

Answer / chandana

To implement a singleton in C#, the steps are:

1. Make the constructor private
2. Declare a static object of the same class
3. Define a static method which return the same object.
This method checks the static variable object, if it
exists, return the same, if it doesn't exist, then creates
a new instance and returns.

This is used when we want to limit the object creation to
only one object for a particular class. e.g., For a
company, we would like to limit the object of type CEO to
be only one. (that means, we know that only 1 CEO exists
for a company).

Is This Answer Correct ?    8 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is inheritance c#?

0 Answers  


Distinguish between continue and break statement?

0 Answers  


What is dynamic in c#?

0 Answers  


What are the 3 different types of arrays?

0 Answers  


Why is xml called extensible?

0 Answers  


What is dynamic object in c#?

0 Answers  


How can I create a process that is running a supplied native executable (e.g., Cmd.exe)?

0 Answers  


What is the difference between int.parse and int.tryparse methods?

0 Answers  


Is system a class in c#?

0 Answers  


What is dataview c#?

0 Answers  


What happens if the inherited interfaces have conflicting method names?

0 Answers  


Where is the output of TextWriterTraceListener redirected?

1 Answers   Rolta, Siebel Systems,


Categories