title | description | ms.date | ms.topic | ms.custom | author | ms.author | manager | ms.subservice |
---|---|---|---|---|---|---|---|---|
Generate a method |
Learn how to use the Quick Actions and Refactorings menu to immediately add a method to a class. |
01/26/2018 |
reference |
ide-ref |
Mikejo5000 |
mikejo |
mijacobs |
general-ide |
This code generation applies to:
-
C#
-
Visual Basic
What: Lets you immediately add a method to a class.
When: You introduce a new method and want to properly declare it, automatically.
Why: You could declare the method and parameters before using it, however this feature will generate the declaration automatically.
-
Place your cursor on the line where there is a red squiggle. The red squiggle indicates a method that doesn't exist yet.
-
Next, do one of the following:
-
Keyboard
- Press Ctrl+. to trigger the Quick Actions and Refactorings menu.
-
Mouse
-
-
Select Generate method from the drop-down menu.
[!TIP] Use the Preview changes link at the bottom of the preview window to see all of the changes that will be made before making your selection.
The method is created with any parameters inferred from its usage.