Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.49 KB

inline-method.md

File metadata and controls

46 lines (30 loc) · 1.49 KB
title description ms.date ms.topic author ms.author manager ms.subservice dev_langs
Inline method
Learn how to use the Quick Actions and Refactorings menu in Visual Studio to refactor inline method declarations and provide a clearer syntax.
11/03/2020
reference
mikadumont
midumont
mijacobs
general-ide
CSharp
VB

Inline method

This refactoring applies to:

  • C#

  • Visual Basic

What: Inline method refactoring.

When: You want to replace usages of a static, instance, and extension method within a single statement body with an option to remove the original method declaration.

Why: This refactoring will provide a more clear syntax.

How-to

  1. Place your caret on the usage of the method.

  2. Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

  3. Select from one of the following options:

    Select Inline <QualifiedMethodName> to remove the inline method declaration:

    Screenshot of the Quick Actions and Refactorings menu in Visual Studio with Convert 'Inline 'CreateWidget()' selected and C# code changes shown.

    Select Inline and keep <QualifiedMethodName> to preserve the original method declaration:

    Screenshot of the Quick Actions and Refactorings menu in Visual Studio with Convert 'Inline and keep 'CreateWidget()' selected and C# code changes shown.

See also