master
bicijinlian 6 years ago
parent ac154ff752
commit 4fb527fead

@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
using System.Collections.Immutable;
namespace LinqStudy.Test.LinqToObject namespace LinqStudy.Test.LinqToObject
{ {
/// <summary> /// <summary>
@ -382,35 +384,30 @@ namespace LinqStudy.Test.LinqToObject
} }
#endregion #endregion
#region Concat #region 串联操作:Concat
///<summary> ///<summary>
/// 串联操作 /// Concat将两个序列合并成一个序列不去重。与Union不同。
///<summary> ///<summary>
public class ConcatTest [Fact]
public void Concat_Test()
{ {
///<summary> List<Person> peoples1 = new List<Person>()
/// Concat将两个序列合并成一个序列不去重。与Union不同。
///<summary>
public void Concat_Test()
{
List<Person> peoples1 = new List<Person>()
{ {
new Person(){ Id=2, Name="小龙女", Age=28}, new Person(){ Id=2, Name="小龙女", Age=28},
new Person(){ Id=4, Name="杨过", Age=32}, new Person(){ Id=4, Name="杨过", Age=32},
}; };
List<Person> peoples2 = new List<Person>() List<Person> peoples2 = new List<Person>()
{ {
new Person(){ Id=2, Name="小龙女", Age=28}, new Person(){ Id=2, Name="小龙女", Age=28},
new Person(){ Id=3, Name="云花公主", Age=16}, new Person(){ Id=3, Name="云花公主", Age=16},
}; };
var concatAct = peoples1.Concat(peoples2); var concatAct = peoples1.Concat(peoples2);
var totalCount = concatAct.Count();
var totalCount = concatAct.Count(); Assert.Equal(4, totalCount);
Assert.Equal(4, totalCount);
}
} }
#endregion #endregion
} }

Loading…
Cancel
Save