實現Foreach遍歷的集合類,需要實現IEnumerable接口,泛型集合則需要實現IEnumerable<T>接口
ListForeach<T> :IEnumerable<T> T : , index = ListForeach(= (index >== T[array.Length *
array =++] = IEnumerator<T> TEnumeratro<T> TEnumeratro<T> : IEnumerator<T> position = - TEnumeratro(T [] array, .arr =.count = = ++ (position <
.position = -
客戶端代碼
Age {; Name { ; Main(<Student> list = ListForeach<Student>( Student() {Age=,Name= Student() { Age = , Name = Student() { Age = , Name = Student() { Age = , Name = Student() { Age = , Name = Student() { Age = , Name = ( s ++<Student> list1 = ListForeach<Student>( Student(){ Age=,Name= Student(){ Age=,Name= Student(){ Age=,Name= Student(){ Age=,Name= ( s + +