CS1624号错误是什么

来源:互联网 发布:哈工程的稳定网络 编辑:程序博客网 时间:2024/06/08 07:18

原文地址:https://support.unity3d.com/hc/en-us/articles/207157773-What-is-CS1624-

症状

当尝试进入Play模式时,我得到了如下错误:

error CS1624: The body of `__’ cannot be an iterator block because `__’ is not an iterator interface type

原因

当使用了迭代器访问器,但是返回类型却不是如下迭代器接口类型中任何一种:IEnumerableIEnumerable<T>IEnumeratorIEnumerator<T>

本例子在一个返回类型为“void”的WaitCheck方法内,使用了迭代器访问器开启了一个协程。

CS1624例子

本例的错误信息如下:

error CS1624: The body of `ExampleScript.WaitCheck()’ cannot be an iterator block because `void’is not an iterator interface type

解决方案

想解决CS1624错误,你需要使用其中一种迭代器接口类型作为返回值类型。

想修复本例子,只要修改WaitCheck方法的返回值类型为IEnumerator迭代器接口类型。

修复CS1624

更多信息

https://msdn.microsoft.com/en-us/library/7e87ybkb(v=vs.90).aspx

0 0