public class People { public string Name; public int Age; public People(string name, int age) { this.Name = name; this.Age = age; } public People Clone() { return new People(this.Name, this.Age); } } List<People> pList = new List<People>(); pList.Add(new People("A", 10)); pList.Add(new People("B", 20)); pList.Add(new People("C", 30)); List<People> pList2 = new List<People>(pList.Count); // 拷贝 pList.ForEach(delegate(People item) { pList2.Add(item.Clone()); });
时间: 2024-10-23 15:57:13