design patterns - Singleton in C# -
i collect more variants create singleton class. please provide me best creation way in c# opinion.
thanks.
public sealed class singleton { singleton _instance = null; public singleton instance { { if(_instance == null) _instance = new singleton(); return _instance; } } // default private constructor can instanctiate private singleton() { } // default private static constructor private static singleton() { } }
i have entire article on may find useful.
oh, , try avoid using singleton pattern in general, due pain testability etc :)
Comments
Post a Comment