Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            People people = new People(
                new Person("张三", 20, new DateTime(1991, 1, 2)),
                new Person("李四", 22, new DateTime(1989, 2, 3)),
                new Person("王五", 25, new DateTime(1986, 3, 10))
                );

            Person person6 = new Person("赵六", 26, new DateTime(1985, 3, 12));
            people.Add(person6);
            Person[] persons = new Person[5];
            people.CopyTo(persons, 0);

            foreach (Person person in people)
            {
                Console.WriteLine(string.Format("name: {0}  age: {1}  birthday: {2}", person.Name, person.Age, person.BirthDay.ToString()));
            }
            Console.WriteLine("===============Person Array Start============");

            for (int i = 0; i <= 1; i++)
            {
                Console.WriteLine(string.Format("name: {0}  age: {1}  birthday: {2}", persons[i].Name, persons[i].Age, persons[i].BirthDay.ToString()));
            }
            //foreach (Person person in persons)
            //{
            //    Console.WriteLine(string.Format("name: {0}  age: {1}  birthday: {2}", person.Name, person.Age, person.BirthDay.ToString()));
            //}

            Console.WriteLine("===============Person Array End============");

            //“赵六”
            Console.WriteLine("========a person start=======");
            Person person_6 = people["赵六"];
            Console.WriteLine(string.Format("name: {0}  age: {1}  birthday: {2}", person_6.Name, person_6.Age, person_6.BirthDay.ToString()));
            Console.WriteLine("========a person end=======");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public void Remove(Person person)
 {
     this._persons.Remove(person);
 }
Ejemplo n.º 3
0
 private void Replace(int index, Person newPerson)
 {
     this._persons[index] = newPerson;
 }
Ejemplo n.º 4
0
 public void Insert(int index, Person person)
 {
     this._persons.Insert(index, person);
 }
Ejemplo n.º 5
0
 public int IndexOf(Person value)
 {
     return IndexOf(value);
 }
Ejemplo n.º 6
0
 public void CopyTo(Person[] persons, int index)
 {
     //((ICollection)this).CopyTo(persons, index);
     this._persons.CopyTo(persons, index);
 }
Ejemplo n.º 7
0
 public bool Contains(Person person)
 {
     return this._persons.Contains(person);
 }
Ejemplo n.º 8
0
 public void Add(Person person)
 {
     this._persons.Add(person);
 }