数组实现IEnumerable< T>吗? [英] does array implements 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< T>吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!