C#中,所有数组都自动继承于System.Array这个抽象类,数组都为引用类型,
所有对数组的更新都会导致源数组的元素值的篡改。
而所有集合的根都来自可枚举接口IEnumerable
数组有三种样式:
数组的Rank(秩)属性代表数组的维数
一维数组【Rank为1】:
T[] array;
锯齿数组【Rank为1】:
锯齿数组本质仍属于一维数组,只不过数组的某一个元素都是数组:
T[][] array;
多维数组【Rank为2~N,秩为逗号个数+1】:
二维,三维等多维数组,使用[,,..,]标识
T[,] array;
数组实现了IList,ICollection等接口,因此数组是一种特殊的集合
所有集合的根都来自可枚举接口IEnumerable
using System.Runtime.InteropServices;
namespace System.Collections
{
[ComVisible(true)]
[Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")]
public interface IEnumerable
{
[DispId(-4)]
IEnumerator GetEnumerator();
}
}
【数组一定是集合,集合不一定是数组】
public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable