Skip to content

Instantly share code, notes, and snippets.

@alexnum
alexnum / Singleton Pattern.cs
Created September 13, 2022 16:37 — forked from OmegaExtern/Singleton Pattern.cs
Singleton Pattern in C#.
#region Singleton Pattern
// NOTE: The class is marked as sealed to prevent the inheritance of the class (i.e. use it as base/super class).
internal sealed class Singleton
{
private static readonly object SingletonSyncRoot = new object();
private static volatile Singleton _instanceSingleton;
// NOTE: Default/Parameterless constructor is private to prevent instantiation of the class.
private Singleton()