What is singleton design pattern ? Write a sample code for singleton implimentation ?
What is the use of it ?
Tell me a Scenario where we can use the singleton design pattern ?
Interviews1 answer
What is Singleton design pattern ? How to implement it ?
1 Answer
public sealed class Singleton
{
static Singleton instance=null;
static readonly object padlock = new object();
Singleton(){}public static Singleton Instance{get{lock (padlock){if (instance==null){instance = new Singleton();}return instance;}}}
}
Imogen HardenPosted Jul 21, 2020, 6:02 AM EDT
