Click here to Skip to main content
13,043,898 members (47,360 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

20.1K views
13 bookmarked
Posted 8 Jul 2011

Simple Singleton Pattern in C#

, 8 Jul 2011
Rate this:
Please Sign up or sign in to vote.
This should do it as well:class Singleton { public static readonly Singleton m_Instance = new Singleton(); // Prevent instance creation from other classes private Singleton() { } public static Singleton Instance { get { return m_Instance; } }}And it is "Singleton",...

This should do it as well:


class Singleton {
    public static readonly Singleton m_Instance = new Singleton();
 
    // Prevent instance creation from other classes
    private Singleton() { }
 
    public static Singleton Instance { get { return m_Instance; } }
}

And it is "Singleton", not a "single Ton"... SCNR

License

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

Share

About the Author


You may also be interested in...

Comments and Discussions

 
QuestionLearn more on http://learn-javascript.in/ Pin
Mayank_Gupta_29-Nov-16 23:56
professionalMayank_Gupta_29-Nov-16 23:56 
QuestionVote 2 Pin
Sinisa Hajnal23-Mar-16 1:21
professionalSinisa Hajnal23-Mar-16 1:21 
QuestionTry this Pin
BhavyaJ3-Mar-15 18:46
memberBhavyaJ3-Mar-15 18:46 
SuggestionSingleton Pattern Example Pin
Developer Hemu Patel8-Aug-14 4:10
memberDeveloper Hemu Patel8-Aug-14 4:10 
GeneralMy vote of 2 Pin
Bartlomiej Filipek6-Oct-13 23:31
memberBartlomiej Filipek6-Oct-13 23:31 
GeneralMy vote of 4 Pin
Peace ON20-Jul-13 0:32
memberPeace ON20-Jul-13 0:32 
GeneralMy vote of 2 Pin
Akhil_Mittal26-Feb-13 22:54
memberAkhil_Mittal26-Feb-13 22:54 
GeneralMy vote of 2 Pin
Oleksandr Kulchytskyi29-Dec-12 3:19
memberOleksandr Kulchytskyi29-Dec-12 3:19 
GeneralReason for my vote of 2 This alternative is not 'lazyloading... Pin
Kabwla.Phone1-Nov-11 3:02
memberKabwla.Phone1-Nov-11 3:02 
GeneralRe: Reason for my vote of 2This alternative is not 'lazyloading... Pin
Ian A Davidson10-Apr-13 15:19
memberIan A Davidson10-Apr-13 15:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 8 Jul 2011
Article Copyright 2011 by schamese
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid