Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Simple Singleton Pattern in C#

By , 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", not a "single Ton"... SCNR


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

About the Author

Software Developer
Germany Germany
No Biography provided

Comments and Discussions

GeneralReason for my vote of 2 This alternative is not 'lazyloading... PinmemberKabwla.Phone1-Nov-11 3:02 
GeneralRe: Reason for my vote of 2This alternative is not 'lazyloading... [modified] PinmemberIan A Davidson10-Apr-13 15:19 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 8 Jul 2011
Article Copyright 2011 by schamese
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid