【发布时间】:2012-11-01 07:53:56
【问题描述】:
如何在 .NET 4.0 中重构收益回报
public static void DoIt()
{
foreach (int n in Power(2,4))
{
Console.Write(n);
}
}
public static IEnumerable CalcPower(int base, int exponent)
{
int res = 1;
for (int c = 1; c <= high; counter++)
{
res = res * base;
yield return result;
}
}
【问题讨论】:
-
什么意思?你的代码有什么问题?它编译吗?它给出正确的结果吗?是否要删除
yield return并用其他内容替换它? -
我会将
public static IEnumerable Power更改为public static IEnumerable<int> Power -
你究竟为什么要使用Tasks?
标签: c#