Select更新

master
bicijinlian 6 years ago
parent f5d750465e
commit 3e901db9ed

@ -0,0 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
using LinqStudy;
namespace LinqStudy.Test.LinqToObject
{
/// <summary>
/// Select 测试
/// </summary>
public class SelectTest
{
[Fact]
public void TestName()
{
// Arrange
var persons = PersonManager.GetPersons();
// Act
var maps=persons.Select(p=>p.Age).ToList();
// Assert
Assert.IsType<List<int>>(maps);
}
}
}

@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace LinqStudy
{
public static class PersonManager
{
public static List<Person> GetPersons()
{
List<Person> persons=new List<Person>()
{
new Person(){Id=1, Name="乐蓉", Age=21},
new Person(){Id=2, Name="陌离殇", Age=46},
new Person(){Id=3, Name="青衫泪", Age=12},
new Person(){Id=4, Name="年华流逝", Age=9},
new Person(){Id=5, Name="念奴娇", Age=47},
new Person(){Id=6, Name="景平", Age=53},
new Person(){Id=7, Name="王高峰", Age=86},
new Person(){Id=8, Name="思菱", Age=37},
new Person(){Id=9, Name="孙瀚昂", Age=52},
new Person(){Id=10, Name="九重吟", Age=87},
new Person(){Id=11, Name="翠巧", Age=28},
new Person(){Id=12, Name="凡雁", Age=47},
new Person(){Id=13, Name="王小姐", Age=13},
new Person(){Id=14, Name="映冬", Age=60},
new Person(){Id=15, Name="李四", Age=72},
new Person(){Id=16, Name="独家等待", Age=84},
new Person(){Id=17, Name="怀蕊", Age=56},
new Person(){Id=18, Name="笑叹红尘", Age=2},
new Person(){Id=19, Name="梦秋", Age=86},
new Person(){Id=20, Name="相思劫", Age=74},
};
return persons;
}
}
}
Loading…
Cancel
Save