日期:2014-05-20 浏览次数:20903 次
//你上面是在转LIst? new {m.Stuendid,m.Studentname}).ToList();
------解决方案--------------------
class Student
{
public int Age { get; set; }
public string Name { get; set; }
public bool Sex { get; set; }
}
private List <Student> GetStudents()
{
List <Student> students = new List <Student> {
new Student{ Name="a", Age=1, Sex =true},
new Student{ Name="b", Age=2, Sex =false},
};
return students;
}
List <Student> tmp = GetStudents.Where(p=>p.Sex ==True);
List<Student> studentList = GetStudents
var stu2 =from st in stulist
select new {name = st.Name, age= st.Age}