編譯器錯誤 CS1627
更新:2007 年 11 月
錯誤訊息
yield return 後面應該有運算式
如果使用 yield 時沒有運算式,便會發生這個錯誤。若要避免這個錯誤,請在陳述式中插入適當的運算式。
下列範例會產生 CS1627:
// CS1627.cs
using System.Collections;
class C : IEnumerable
{
public IEnumerator GetEnumerator()
{
yield return; // CS1627
// To resolve, add the following line:
// yield return 0;
}
}
public class CMain
{
public static void Main() { }
}