using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ControlProject { class User { public string Name { get; set; } public int Age { get; set; } public User() { } public User(string name,int age) { this.Name = name; this.Age = age; } } class Program { static void Main(string[] args) { User u1 = new User("神秘藏宝室",26); User u2 = new User("神秘", 26); User u3 = new User("藏宝室", 26); User[] myUser = { u1, u2, u3 }; foreach(User u in myUser) { Console.WriteLine("用户:{0},年龄:{1}", u.Name, u.Age); } } } }