Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Visual Studio
Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
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
Place your cursor in the local function.

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

Press Enter to accept the refactoring.
