-
[WPF] Singleton ClassC#/WPF 2023. 11. 28. 10:08
private static readonly Lazy<클래스이름> instance = new Lazy<클래스이름>(() => new 클래스이름()); public static 클래스이름 Instance { get { return instance.Value; } }
EX)
private static readonly Lazy<TagClient> instance = new Lazy<TagClient>(() => new TagClient()); public static TagClient Instance { get { return instance.Value; } }
public sealed class Singleton { private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(() => new Singleton()); public static Singleton Instance { get { return lazy.Value; } } private Singleton() { } }
https://csharpindepth.com/Articles/Singleton
https://ivorycirrus.github.io/TIL/csharp-singleton/
728x90'C# > WPF' 카테고리의 다른 글
[WPF] kakaotalk 예제 (0) 2024.01.03 [WPF] ListBox SelectItem Don't Focus (0) 2023.12.07 [WPF] TreeView (0) 2023.11.21 [WPF] ObservableCollection<> Binding (0) 2023.11.02 [WPF] Pre-build event/post-build event (0) 2023.10.17 댓글