Skip to content

Instantly share code, notes, and snippets.

@SupinePandora43
Created April 20, 2022 13:52
Show Gist options
  • Save SupinePandora43/57d038a04c4c2bf1a379b6a511476fa9 to your computer and use it in GitHub Desktop.
Save SupinePandora43/57d038a04c4c2bf1a379b6a511476fa9 to your computer and use it in GitHub Desktop.
Struct destructor

Struct

public ref struct S {
    public S() => Console.WriteLine("Constructor");
    public void DoWork() => Console.WriteLine("*Work*");
    public void Dispose () => Console.WriteLine("Destructor");
}

Usage

public static void Idk(){
    using S s = new();
    s.DoWork();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment