Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //se la classe non verrà mai estesa è corretto chiamarla come sealed, altrimenti il singleton può essere utile anche attraverso l'ereditarietà
- class Singleton
- {
- //istanza corrente
- private static Singleton Instance = null;
- //metodo di ritorno singola istanza
- public static Singleton GetInstance()
- {
- if(Singleton.Instance == null)
- Singleton.Instance = new Singleton();
- return Singleton.Instance;
- }
- //costruttore privato per inibire l'instanziazione al di fuori della classe
- private Singleton()
- {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement