Skip to content

Latest commit

 

History

History
40 lines (26 loc) · 1.41 KB

convert-local-function-method.md

File metadata and controls

40 lines (26 loc) · 1.41 KB
title description ms.date ms.topic author ms.author manager ms.subservice
Convert a local function to a method
Learn how to use the Quick Actions and Refactorings menu to convert a local function to a method.
02/19/2019
reference
mikadumont
midumont
mijacobs
general-ide

Convert a local function to a method

This refactoring applies to:

  • C#

What: Convert a local function to a method.

When: You have a local function that you want to define outside your current local context.

Why: You want to convert a local function into a method so that you can call it outside your local context. You might want to convert to a method when your local function is getting too long. When you define the function in a separate method, your code is easier to read.

Convert local function to method refactoring

  1. Place your cursor in the local function.

    Convert a local function to a method code sample

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

    Convert local function to method code fix sample

  3. Press Enter to accept the refactoring.

    Convert local function to method result sample

See also