用类名声明数组
用类声明的数组对象,相当于一个包含不同对象名的数组
using System;
using System.Collections.Generic;
using System.Text;
namespace _3_7Lesson
{
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public override string ToString()
{
return string.Format
("Person:FirstName={0},LastName={1}", FirstName, LastName);
}
public Person()
{
}
}
class Program
{
static void Main(string[] args)
{
Person [] myperson = new Person [2];
myperson[0] = new Person { FirstName = "audi", LastName = "senna" };
Person person1 = myperson [0];
Console.WriteLine(myperson[0].ToString ());
Console.ReadKey();
}
}
}