【求助】List<T> t;这句代码如何理解?
List<T> t;这句代码如何理解?其中T表示一个类,t表示T类的对象
public class SeqList<T> { private T[] dataItems; private int size; public SeqList() { dataItems = new T[256]; size = 0; } public int Size { get { return size; } } public T this [ int i] { get { return dataItems[i]; } } public void Delete(T item) { if (this.size == 0) { return; } else { int index = -1; for (int i = 0; i < this.size; i++) { object obj1 = dataItems[i] as object; object obj2 = item as object; if ( obj1.Equals( obj2)) { index = i; break; } } while (index < size - 1) { dataItems[index] = dataItems[index + 1]; index++; } } } public void Insert(T item) { if (size < 256) { dataItems[size] = item; size++; } } public void Insert(T item, int index) { if (size < 256 && index < size) { int saveIndex = index; T temp = dataItems[ index], temp_1; while (index < size) { temp_1 = dataItems[ index + 1]; dataItems[index + 1] = temp; temp = temp_1; } dataItems[saveIndex] = item; } } public int Find(T item) { for (int index = 0; index < size; index++) { object obj1 = dataItems[index] as object; object obj2 = item as object; if ( obj1.Equals( obj2)) { return index; } } return -1; } public void ClearList() { this.size = 0; } } public class Program { private static SeqList<int> list = new SeqList<int>(); public static void Main() { Random random = new Random(DateTime.Now.Second); for (int i = 0; i < 10; i++) { list.Insert(random.Next(1, 100)); } PrintList<int>(list); Console.ReadKey(); } public static void PrintList<T>(SeqList<T> list) { for (int i = 0; i < list.Size; i++ ) { Console.Write(list[i] + " "); } Console.WriteLine(); } }