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 ?
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; } }}
Singleton()
{
}
public static Singleton Instance
get
lock (padlock)
if (instance==null)
instance = new Singleton();
return instance;