private T[] _list; public void Init(int maxCapcity = 100) { if (maxCapcity <= 0) throw new ArgumentException("maxCapcity无效"); _maxCapcity = maxCapcity; _list = new T[maxCapcity]; } private int _length; public int Lenght { get { return _length; } } private int _maxCapcity; public int MaxCapcity { get { return _maxCapcity; } } public T this[int index] { get { if (index >= Lenght) throw new IndexOutOfRangeException("index"); return _list[index]; } set { if (index >= MaxCapcity) throw new IndexOutOfRangeException("index"); _list[index] = value; } }