I have 2 List. The first one, lets call it ListA is more like a complete list and the second one ListB is a modified list. Now what I want to do i
As I consider, you want to update only an age. Also you don't need to use Where().First() you can use just First().
foreach (var x in ListB)
{
var itemToChange = ListA.First(d => d.Name == x.Name).Age = x.Age;
}
If you are not sure, that item exists in ListA you should use FirstOrDefault() and if statement to check it.
foreach (var x in ListB)
{
var itemToChange = ListA.FirstOrDefault(d => d.Name == x.Name);
if (itemToChange != null)
itemToChange.Age = x.Age;
}