开发者

Removing unused local variables from .NET code

Is there a tool available that can scan a C# or VB.NET project 开发者_如何学Goand automatically remove all unused local variables?


Ahem: FxCop and ReSharper are nice and all, but the compiler will happily ignore unused variables and never even declare them in compiled code if you enable the optimize option.


You can use ReSharper. It will mark all unused variables and allow you to remove them.


It looks like ReSharper should help you clean up your code.


You can use FxCop to analyse your code.

Our you van install resharper that greys unused local variables out

With both tools you have to delete them your self


FxCop is a useful tool in a number of ways, one of which is that it will point out unused variables and parameters. This is helpful if you have your code going through a continuous integration process.

ReSharper will highlight unused variables and parameters when you are in Visual Studio.

Neither tool will automatically do the removal for you, although it's usually a simple thing to do...R# even provides a shortcut command to remove a single selected variable for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜