. , T:
public List(int capacity)
{
if (capacity < 0)
throw new ArgumentException();
if (capacity == 0)
this._items = List<T>._emptyArray;
else
this._items = new T[capacity];
}
, . , . , . :
List<string> lFiles = new List<string>(12);
Console.WriteLine(lFiles.Count);
Console.WriteLine(lFiles.Capacity);
, "" (.. , ):
public int Count
{
get { return this._size; }
}
. .
public void Add(T item)
{
if (this._size == this._items.Length)
this.EnsureCapacity(this._size + 1);
this._items[this._size++] = item;
this._version++;
}
- , , ( , , ). , , (.. , ):
public void Insert(int index, T item)
{
if (index > this._size)
throw new ArgumentOutOfRangeException();
if (this._size == this._items.Length)
this.EnsureCapacity(this._size + 1);
if (index < this._size)
Array.Copy(_items, index, this._items, index + 1, this._size - index);
this._items[index] = item;
this._size++;
this._version++;
}