Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

singleton pattern c#

public sealed class Singleton
    {
    private static readonly Singleton instance = new Singleton();

    // Explicit static constructor to tell C# compiler
    // not to mark type as beforefieldinit
    static Singleton()
    {
    }

    private Singleton()
    {
    }

    public static Singleton Instance
    {
    get
    {
    return instance;
    }
    }
    }
Source by csharpindepth.com #
 
PREVIOUS NEXT
Tagged: #singleton #pattern
ADD COMMENT
Topic
Name
6+1 =