0
我创建了一个“反向itearator”对于一个LinkedList,现在我想用的扩展方法使用一个LinkedList:C#:访问反向枚举数
public static class LinkedListExtensionMethods
{
public static IEnumerator GetReverseEnumerator<T>(this LinkedList<T> linkedList)
{
return new LinkedListReverseEnumerator<T>(linkedList);
}
public static IEnumerator<T> GetReverseGenericEnumerator<T>(this LinkedList<T> linkedList)
{
return new LinkedListReverseEnumerator<T>(linkedList);
}
}
但是,如果我写的:
foreach (ICommand command in _CompoundDoCollection.GetReverseEnumerator<ICommand>())
它不起作用。
我该怎么办?
“不起作用”是什么意思?它会抛出一个错误,结果不是你所期望的吗?它不会编译? etc – taylonr 2011-04-25 14:44:26
为什么一个'反向'枚举器,当你可以通过一个普通的枚举器向后迭代? – 2011-04-25 14:47:29
@Cos,你如何通过普通的枚举器向后迭代? – svick 2011-04-25 14:51:03