Domanda

How to implement singleton design pattern in C#?
Can anyone help me?

È stato utile?

Soluzione

In singleton pattern, a class can only have one instance and provides access point to it globally.

public sealed class Singleton
{
     private static readonly Singleton _instance = new Singleton();
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top