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...


Singleton Design pattern?How do you achieve it?

Answers were Sorted based on User's Feedback



Singleton Design pattern?How do you achieve it?..

Answer / mithun kanungo

We Can Achieve Singleton Design Pattern By restricting Other
Class To Make Object of the class By Using Constructor
instead we can Use A Static Method to get hold of the
Instance of the class , And By making our Constructor
private we can Restrict other classes to make Instance of
the Class , So that All other Classes use the same static
method to make only one instance of the class.

Is This Answer Correct ?    6 Yes 0 No

Singleton Design pattern?How do you achieve it?..

Answer / shijas

Singleton design pattern we can implement using Static key
word that means only one instance.All the instances are
coming from the same memory location.

Is This Answer Correct ?    3 Yes 0 No

Singleton Design pattern?How do you achieve it?..

Answer / sudhir sheoran

Singleton design pattern can be achieved by following implementation:

1) Make class public

2) Static method to generate the instance of class(calling this method we can get the instance of a class if already a instance is generated we will get the same instance)

3) Private Constructor (so that no other class can generate the instance of singleton class)

Example::

class Class1
{
private static Class1 classInstance;
private IList<int> list = new List<int>();
private Class1()
{
if (list == null)
{
list = new List<int>();
}

}

public static void GetInstance()
{
if (classInstance == null)
{
classInstance = new Class1();
}

}
}

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

What is web.config. How many web.config files can be allowed to use in an application?

6 Answers   Accenture, HCL, InterGraph, iSoft,


how to add cliet side event to server side? and how to register client script to sever side? wt difference these two

3 Answers   PSI Data Systems,


3. What goals do you have in your career?

0 Answers   Swatz Oils,


What is cyclomatic complexity and why is it important?

1 Answers  


which event in global.asx that fires for every request of same user?

4 Answers   FactorH,


5. What three Specific Job Positions do you target from Swatz Oils GROUP U.K?

0 Answers   Swatz Oils,


In asp.net, how can you validate drop down box?

0 Answers   Accenture,


Types of configuration files and their differences ?

2 Answers   Accenture,


How To Generate ConnectionString By Using Notepad??

2 Answers  


What is true about application service provider?

0 Answers  


What are the versions of garbage collection?

0 Answers   Proteans,


What is mvc structure? given example? How to show gridview control from business components and using class object arrays?

3 Answers  


Categories