如何在 C# 和 Asp.net 中使用 Linq 从数组中获取所有模块,如下所示,其中学生名字。这可能是很容易做到的事情,但未能掌握窍门。请帮忙。谢谢。
ArrayList arrList = new ArrayList(); //new array list for students
arrList.Add(
new Student
{
FirstName = "Svetlana",
LastName = "Omelchenko",
Password = "hh",
modules = new string[] { "001", "002", "003", "004" }
});
arrList.Add(
new Student
{
FirstName = "Claire",
LastName = "O’Donnell",
modules = new string[] { "001", "002", "003", "004" }
});
arrList.Add(
new Student
{
FirstName = "Sven",
LastName = "Mortensen",
modules = new string[] { "001", "002", "003", "004" }
});
arrList.Add(
new Student
{
FirstName = "Cesar",
LastName = "Garcia",
modules = new string[] { "HH", "KK", "LL", "OO" }
});
var query = from Student student in arrList
where student.FirstName == "Cesar"
select query;
GridView1.DataSource = query;
GridView1.DataBind();
我想将结果放入 Asp.net 中的网格表中。请帮忙!!