更新:2007 年 11 月
错误消息
迭代器不能有 ref 或 out 参数
如果迭代器方法带有 ref 或 out 参数,则会发生此错误。若要避免此错误,请从方法签名中移除 ref 或 out 关键字。
示例
下面的示例生成 CS1623:
// CS1623.cs
using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return 0;
}
// To resolve the error, remove ref
public IEnumerator GetEnumerator(ref int i) // CS1623
{
yield return i;
}
// To resolve the error, remove out
public IEnumerator GetEnumerator(out float f) // CS1623
{
f = 0.0F;
yield return f;
}
}