I have a long method, and for reading clarity would like to put some of the code in a separate method. However, that can’t be done because that code uses the variables in the method. So I would like to put that code somewhere else and tell the compiler to insert that code in “this” place when compiling. Is there any way to do that?
I’m using visual studio.
I have a long method, and for reading clarity would like to put some
Share
Sounds like you’re describing the Extract method and you can do this very easily, simply highlight the code you want to move and:
Right click -> Refactor -> Extract method -> Enter method name
Visual studio will deal with the rest for you. Read the docs here.