Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.76 KB

generate-deconstructor.md

File metadata and controls

49 lines (34 loc) · 1.76 KB
title description ms.date ms.topic author ms.author manager ms.subservice dev_langs
Generate a deconstructor quick action
Learn how to use the Quick Actions and Refactorings menu to immediately generate the method stub for a new deconstructor.
02/19/2019
reference
mikadumont
midumont
mijacobs
general-ide
CSharp

Generate a deconstructor in Visual Studio

This code generation applies to:

  • C#

What: Lets you immediately generate the method stub for a new deconstructor.

When: You want to properly deconstruct your type automatically.

Why: You can manually type a deconstructor, but this feature generates the stub for you with the correct out parameters.

Generate a deconstructor

  1. Declare a new type with the desired out parameters specified. This declaration will cause an error when no deconstruct instance matching your declaration can be found.

    Missing deconstructor error

  2. Take one of the following steps:

    • Keyboard

      • With the cursor in your declaration, select Ctrl+. to trigger the Quick Actions and Refactorings menu.
    • Mouse

      • Right-click and select the Quick Actions and Refactorings menu.
      • Select the :::image type="icon" source="media/screwdriver.png"::: icon that appears in the left margin if the text cursor is already on the empty line in the class.

      Generate deconstructor code fix

  3. Select Generate method 'MyInternalClass.Deconstruct' to generate the deconstructor.

    Resulting deconstructor code

See also