does array implements IEnumerable?

后端 未结 3 1228
北恋
北恋 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条回答
  •  Happy的楠姐
    2021-01-25 11:30

    Official word here

    Array Overview

    An array has the following properties:

    • An array can be Single-Dimensional, Multidimensional or Jagged.

    • The number of dimensions and the length of each dimension are established when the array instance is created. These values can't be changed during the lifetime of the instance.

    • The default values of numeric array elements are set to zero, and reference elements are set to null.

    • A jagged array is an array of arrays, and therefore its elements are reference types and are initialized to null.

    • Arrays are zero indexed: an array with n elements is indexed from 0 to n-1.

    • Array elements can be of any type, including an array type.

    • Array types are reference types derived from the abstract base type Array. Since this type implements IEnumerable and IEnumerable, you can use foreach iteration on all arrays in C#.

提交回复
热议问题