转换为方法组ReSharper的 [英] Convert to Method Group Resharper
本文介绍了转换为方法组ReSharper的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了下面的方法是这样的:
I have written a method below like this:
internal static IList<EmpowerTaxView> GetEmpowerTaxViewsByLongAgencyAndAgencyTaxTypes(
IList<EmpowerCompanyTaxData> validEmpowerCompanyTaxDatas,
IList<EmpowerTaxView> empowerTaxViews)
{
IList<EmpowerTaxView> result = new List<EmpowerTaxView>();
foreach (EmpowerCompanyTaxData empowerCompanyTaxData in validEmpowerCompanyTaxDatas)
{
IList<EmpowerTaxView> validEmpowerTaxViews =
GetEmpowerTaxViewsByLongAgencyAndTaxType(
empowerCompanyTaxData, empowerTaxViews);
validEmpowerTaxViews.ToList().ForEach(delegate(EmpowerTaxView etv)
{
result.Add(etv);
});
}
return result;
}
和此方法,ReSharper的说:
And for this method, the resharper says:
validEmpowerTaxViews.ToList().ForEach(delegate(EmpowerTaxView etv)
{
result.Add(etv);
});
转换为方法组。这是什么意思,应该怎么做才能摆脱这一点。
Convert to Method Group. What does this mean and what should be done to get rid of this.
推荐答案
JaredPar已经提供了正确的答案,我只是想建议一个简单的实现方法:
JaredPar already provided the correct answer, I just wanted to suggest a simpler implementation of the method:
internal static IList<EmpowerTaxView> GetEmpowerTaxViewsByLongAgencyAndAgencyTaxTypes(
IList<EmpowerCompanyTaxData> validEmpowerCompanyTaxDatas,
IList<EmpowerTaxView> empowerTaxViews)
{
var results =
from empowerCompanyTaxData in validEmpowerCompanyTaxDatas
from etv in GetEmpowerTaxViewsByLongAgencyAndTaxType(
empowerCompanyTaxData, empowerTaxViews)
select etv;
return results.ToList();
}
这篇关于转换为方法组ReSharper的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文