我正在尝试更改类对象中的值。是否有任何这样做。我正在尝试在UI中动态显示更新。(xaml)
我的课程:
public class Students
{
public int id;
public string Name;
public int Age;
}
//Students studs = new Students();
public ObservableCollection<Students> studs = new ObservableCollection<Students>();
Students studs_temp = sender as Students; // Read data in tapped function
int index = studs.IndexOf();
//Here I need to alter the Age of Student in studs where the id
is equal to id in studs_temp.
答案 0 :(得分:1)
这样的事情:
public class Student
{
public int id;
public string Name;
public int Age;
}
在你的消费方法中:
List<Student> students = new List<Student>();
// ...
// populate your list
// ...
// select the student with a particular ID
Student s = students.Single(x => x.id == myID);
// now alter the age of that student
s.Age = 23;