How to refactor a lambda event handler to the classical method using Resharper or Visual studio refactoring tools? The problem, apparently, because of closure. A开发者_Go百科nd it is not always possible to convert lambda event handler to the method.
I don't know if this is the best way to do it, but I did it about 2 minutes ago. (If you have re-sharper) Copy the code inside the lambda and then delete the method to just before += and then hit ctrl-alt-space and in the re-sharper dropdown select the CreateMethod option. Now paste the code into the method that re-sharper has created
if the method signatures are correct, you can do an extract method on the body of the lambda and then inline the lambda.
精彩评论