实现在C#中的双向枚举 [英] Implementing a bidirectional enumerator in C#

查看:266
本文介绍了实现在C#中的双向枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用产量块实施的IEnumerator℃的途径; T> 可向后移动( MoveLast()),以及前锋?

Is there a way to use yield blocks to implement an IEnumerator<T> which can go backward (MoveLast()) as well as forward?

推荐答案

而不是直接从迭代器块,没有。

Not directly from the iterator block, no.

然而,主叫方总是可以缓冲的结果,例如成列表< T> ,或只需拨打反向( ) - 但这并不总是适用

However, the caller can always buffer the results, for example into a List<T>, or just call Reverse() - but this doesn't always apply.

这篇关于实现在C#中的双向枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆