The singleton template implementation proposed in C # in depth ,
public sealed class Singleton { private static readonly Singleton instance = new Singleton(); static Singleton() { } private Singleton() { } public static Singleton Instance { get { return instance; } } }
ReSharper suggests simplifying this by using the auto property and the C # 6 auto-source initializer:
public sealed class Singleton { static Singleton() { } private Singleton() { } public static Singleton Instance { get; } = new Singleton(); }
It really looks easier. Is there any way to use this simplification?
c # singleton resharper
Petter t
source share