does array implements IEnumerable?

后端 未结 3 1190
北恋
北恋 2021-01-25 11:03

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

public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IS         


        
3条回答
  •  -上瘾入骨i
    2021-01-25 11:30

    You can check it simply like this:

    var type = typeof(int[]); // or any other type
    foreach (var @interface in type.GetInterfaces())
        Console.WriteLine(@interface);
    

    Result is:

    System.ICloneable
    System.Collections.IList
    System.Collections.ICollection
    System.Collections.IEnumerable
    System.Collections.IStructuralComparable
    System.Collections.IStructuralEquatable
    System.Collections.Generic.IList`1[System.Int32]
    System.Collections.Generic.ICollection`1[System.Int32]
    System.Collections.Generic.IEnumerable`1[System.Int32]
    System.Collections.Generic.IReadOnlyList`1[System.Int32]
    System.Collections.Generic.IReadOnlyCollection`1[System.Int32]
    

提交回复
热议问题