【发布时间】:2014-07-21 22:12:48
【问题描述】:
我无法弄清楚如何正确执行此操作。我在代码的最后一行收到此错误。错误说:
"不能隐式转换类型 'System.Collections.Generic.List 到 'System.Collections.Generic.IEnumerator'。显式 存在转换(您是否缺少演员表?)
这是函数的代码:
public IEnumerator<string> AddElementsAttributesRemoveElementsAttributes()
{
List<string> retval = new List<string>();
try
{
success = false;
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
return retval;
}
我该如何解决这个问题?我是否需要以某种方式将返回值转换为不同的类型?
【问题讨论】:
-
为什么需要将其返回为
IEnumerator<string>而不是IEnumerable<string>? -
是我还是“存在显式转换”在这里根本没有帮助?
标签: c#