我有out
參數等的方法:提取類OUT參數中
void Do(int anInput, out List<string> items, out int count)
{
/* some code */
}
現在我想變換籤名,這樣的輸出參數是由是由法像返回的對象取代:
DoResult Do(int anInput)
{
/* some code */
return new DoResult{Items=TODO, Count=TODO};
}
class DoResult {
public List<string> Items;
public int Count;
}
在Visual Studio 2010或ReSharper 7中是否存在對這種轉換的重構?
我知道ReSharper重構從參數提取類。但它似乎對out
參數沒有幫助。
更新: Daniel A. White的答案非常適合.Net 4.0。有.Net 3.5的解決方案嗎?一代元組也可以。
你真的需要這個自動化嗎?你有多少地方需要改變?手動操作應該相當容易。 – 2013-04-09 12:48:36
這將是一個很少使用的功能。但我很懶。 :-)通過ReSharper的_Extract Method_重構,我得到了帶有2個'out'參數的方法。 – thersch 2013-04-09 13:03:52
但與尋求自動化解決方案相比,您現在需要做多少工作才能進行重構? – 2013-04-09 13:06:11