Enumerable.Range implementation

后端 未结 4 1645
失恋的感觉
失恋的感觉 2020-12-20 08:21

What is the precise implementation of Enumerable.Range in .Net; preferable .Net 4? Is it a yielded for-loop? A custom implementation (IEnumerable, IEnumerator) or?<

4条回答
  •  攒了一身酷
    2020-12-20 08:54

    You can use Reflector to see the implementation for yourself. It checks arguments and throws exception at the time of calling, so the Range method itself is not an iterator method. It calls another method which is an iterator method. It's not OK to post the exact code due to license restrictions.

提交回复
热议问题