编译器错误 CS1625
更新:2007 年 11 月
错误消息
无法在 finally 子句体内生成
在 finally 子句体内不允许出现 yield 语句。若要避免此错误,请将 yield 语句移到 finally 子句的外部。
下面的示例生成 CS1625:
// CS1625.cs
using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
try
{
}
finally
{
yield return this; // CS1625
}
}
}
public class CMain
{
public static void Main() { }
}