Edit

Share via


Singleton<T> Class

Definition

Caution

This helper will be removed in a future release, see example tag for code replacement. https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134

[System.Obsolete("This helper will be removed in a future release, see example tag for code replacement. https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134")]
public static class Singleton<T> where T : new()
[<System.Obsolete("This helper will be removed in a future release, see example tag for code replacement. https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3134")>]
type Singleton<'T (requires 'T : (new : unit -> 'T))> = class
Public Class Singleton(Of T)

Type Parameters

T

The type to be used for creating the Singleton instance.

Inheritance
Singleton<T>
Attributes

Examples

Instead of this helper, migrate your code to this pattern instead:

// Setup Singleton
public class MyClass
{
    public static MyClass Instance { get; } = new MyClass();
}

Properties

Instance

Gets the instance of the Singleton class.

Applies to