I have a ObservableCollection<AnyClass>
collection. This collection has data like ID, first name, second name开发者_开发技巧, address, pin, city, Salary and Description.
I want to change the description of this collection whose id is 10 or 12 or any ID.
Thanks in advance.
Try this:
foreach(var item in collection.Where(x => x.ID == 10))
{
item.Description = newDescription;
}
Although it is old question, someone may find my answer useful.
You can do this by using LINQ to find necessary item using appropriate predicate and then modify.
var selectedItem = myCollection.FirstOrDefault(x => x.Id == 10);
if (selectedItem != null)
{
selectedItem.Description = "Do something";
}
Hope it helped to someone.
精彩评论