数组实现IEnumerable< T>吗? [英] does array implements IEnumerable<T>?

查看:60
本文介绍了数组实现IEnumerable< T>吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道基本抽象Array类没有实现泛型IEnumerable作为

I know that the base abstract Array class doesn't implement generic IEnumerable as

public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable
{
 ...
}

所以当我创建像int[] i;string[] s;这样的派生数组类时,它们实现了IEnumerable<T>吗?以及如何查看[]的源代码?

so when I create a derive array class like int[] i; or string[] s;, do they implement IEnumerable<T>? And how can I see the source code of []?

推荐答案

有一个特殊类型SZArrayHelper-数组包装.这是源代码: https://referencesource.microsoft.com/#mscorlib /system/array.cs,aa97964558672440

There is special type SZArrayHelper - wrapper around array. Here is source code: https://referencesource.microsoft.com/#mscorlib/system/array.cs,aa97964558672440

此外,数组实现了IList,它实现了ICollection,并且实现了IEnumerable.因此,Array实现了IEnumerable

Also, array implements IList, and it implements ICollection and it implements IEnumerable. So, Array implements IEnumerable

这篇关于数组实现IEnumerable&lt; T&gt;吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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