編譯器錯誤 CS1623
更新:2007 年 11 月
錯誤訊息
Iterator 不能有 ref 或 out 參數
如果 Iterator 方法採用 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;
}
}