vue-java-tutorials/CSharp/SQLTutorial/SingletonPattern/Singleton.cs

17 lines
339 B
C#

namespace SingletonPattern;
public class Singleton
{
private static readonly Lazy<Singleton> LazyInstance = new(() => new Singleton());
private Singleton()
{
}
public static Singleton Instance => LazyInstance.Value;
public void SomeMethod()
{
Console.WriteLine("Singleton method called");
}
}