[英]In VS Is there a way to change all derived classes method arguments at once?
基本上是標題。 但是我將提供一個示例,以防我沒有正確說出它的意思。
public abstract class A
{
public abstract void Method(Foo foo);
}
public class B : A
{
public override void Method(Foo foo)
{
throw new System.NotImplementedException();
}
}
public class C : A
{
public override void Method(Foo foo)
{
throw new System.NotImplementedException();
}
}
我想一次更改與“ A類”相關的每個類的(Foo foo)。 我可以查找並替換,但是如果在其他任何地方使用該方法名稱,則可能會損壞其他代碼。
我打算從抽象派生數百個類,所以我想知道我可以沿線進行更改。
在Visual Studio 2017中(無ReSharper),這取決於您所說的“更改”。 通過突出顯示方法名稱,然后選擇“ Edit
->“ Refactor
->“ Remove Parameters
或“ Edit
->“ Refactor
->“ Reorder Parameters
可以刪除和重新Reorder Parameters
。 但是,如果沒有諸如ReSharper之類的東西,就無法更改現有參數的類型和/或名稱(據我所知)。
來源: https : //docs.microsoft.com/zh-cn/visualstudio/ide/reference/change-method-signature
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.