小唯快跑啊
像这样:firstList.AddRange (secondList);或者,您可以使用System.Linq中定义的“ Union”扩展方法。使用“联合”,您还可以指定一个比较器,该比较器可用于指定是否应合并项目。像这样:List<int> one = new List<int> { 1, 2, 3, 4, 5 };List<int> second=new List<int> { 1, 2, 5, 6 };var result = one.Union (second, new EqComparer ());foreach( int x in result ){ Console.WriteLine (x);}Console.ReadLine ();#region IEqualityComparer<int> Memberspublic class EqComparer : IEqualityComparer<int>{ public bool Equals( int x, int y ) { return x == y; } public int GetHashCode( int obj ) { return obj.GetHashCode (); }}#endregion