Click here to Skip to main content
15,883,705 members
Articles / Programming Languages / C#

common Singleton Pattern implementation using Generic

Rate me:
Please Sign up or sign in to vote.
2.67/5 (3 votes)
17 Oct 2011CPOL 20.2K   7  
Customized implementation of the Singleton pattern using Generics.

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
5 Oct 2011Paulo Zemek
All classes are naturally Lazy loaded.So a better implementation will be:public class Singletonwhere T: new(){ public static readonly T Instance = new T();}You will notice that before calling the singleton class, the object will not be loaded.Surely there are...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer mp3lyric.us
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions