举个栗子
类定义
public class test
{
public test(int _id,
int _age,
string _name)
{
id = _id;
age =_age;
name =_name;
}
public int id;
public int age;
public string name;
}
List<test> t=new List<test>();
t.Add(new test( 1, 2, "asd1"));
t.Add(new test( 2, 2, "esd2"));
t.Add(new test(3, 2, "we2" ));
t.Add(new test( 4, 2, "sa"));
List<string> test2= t.Select(x => x.name).ToList();
Dictionary<int, string> dicname= t.ToDictionary(x => x.id, y => y.name);