。
Lists= new student()
{
new student {name ="11111",adress ="22222"},
new student {name ="22222",adress ="22222"},
new student {name ="33333",adress ="22222"}
}
正确的写法其实是这样的:
using System.Collections.Generic;
using System.Linq;
public static void Test()
{
var students = new List()
{
new Student {Name = "11111", Adress = "22222"},
new Student {Name = "22222", Adress = "22222"},
new Student {Name = "33333", Adress = "22222"}
};
var list = students.Where(o => o.Name == "22222").ToList();
foreach (var student in list)
{
student.Adress = "00000";
}
}
private class Student
{
public string Name { get; set; }
public string Adress { get; set; }
}