示例#1
0
 /// <summary>
 /// 普通实体数组
 /// </summary>
 private static void Test1()
 {
     Person[] persons = new Person[2];
     persons[0] = new Person { Name = "seasun", Age = 26 };
     persons[1] = new Person { Name = "candy", Age = 25 };
     foreach (var p in persons)
     {
         Console.WriteLine("{0} is {1}", p.Name, p.Age);
     }
 }
示例#2
0
 /// <summary>
 /// 实现IEnumerable, IEnumerator
 /// </summary>
 private static void Test3()
 {
     Person[] persons = new Person[3];
     persons[0] = new Person { Name = "seasun", Age = 26 };
     persons[1] = new Person { Name = "candy", Age = 25 };
     persons[2] = new Person { Name = "qing", Age = 27 };
     People people = new People(persons);
     Console.WriteLine("{0} is {1}", people[0].Name, people[0].Age);
     foreach (Person p in people)
     {
         Console.WriteLine("{0} is {1}", p.Name, p.Age);
     }
 }
示例#3
0
 public People(Person[] persons)
 {
     Console.WriteLine("position : {0}", position);
     _persons = persons;
 }