开发者

Refactoring lambda to method for event

开发者 https://www.devze.com 2023-02-25 06:58 出处:网络
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 possib

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消