I'm using a list adding items from a class. I need to replace all items in same row using where statement. Example
public class Foo
{
public string name { get; set; }
public string SubName { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
List<Foo> mItems = new List<Foo>();
mItems.Add(new Foo { name = "Name", SubName = "Subname" });
mItems.Add(new Foo { name = "Name2", SubName = "Subname2" });
mItems.Add(new Foo { name = "Name3", SubName = "Subname3" });
if (mItems.Any(x => x.name == "Name3"))
{
//where name is Name3 replace Name3 with Name4 and SubName3 with Subname4
}
}
I need to replace where name is Name3 the both of values. Name3 and subname3. I tried to use replace but it doesn't show it in suggested.