简体   繁体   English

Visual Studio 2015重构方法签名

[英]Visual studio 2015 refactor method signature

When adding a parameter to a method call, VS refactoring suggest to create new overloaded method with empty implementation. 将参数添加到方法调用时,VS重构建议使用空实现创建新的重载方法。

Is it possible to change the existing method implementation by adding a parameter to the method? 是否可以通过向方法添加参数来更改现有方法的实现?

For example: Assuming method A is: 例如:假设方法A为:

public void A(int i)
{
   Console.Debug(i)
}

And this method is called: 这种方法称为:

 A(5);

and this changed to 这变成了

A(5,"string");

now I want to change the method to be: 现在我想将方法​​更改为:

public void A(int i,string s)
{
   Console.Debug(i)
}

rather than that a new overloaded is created with not implemented exception: 而不是创建一个未实现异常的新重载:

public void A(int i,string s)
{
   throw new NotImplementedException();
}

Visual studio can't do that but Resharper can. Visual Studio无法做到这一点,但是Resharper可以做到。

Resharper suggest you to modify the existing implementation Resharper建议您修改现有实施

Visual studio as an IDE it won't deeply suggest like how Resharper does. Visual Studio作为一种IDE,不会像Resharper那样深刻地暗示。 Resharper is specifically to ease the way of refactoring and specially to adore coding standards. Resharper专门用于简化重构方式,并且特别适合于编码标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM