What is the LINQ-version of the following code-snippet:
List<Car> myCarList = ...;
foreach(Car c in myCarList)
{
if(c.Name.Equals("VW Passat"))
{
c.Color = Colors.Silver;
}
}
i tried Select like this and it works:
myCarList = myCarList.Where(c=>c.Name.Equals("VW Passat")).Select(c=> new Car(){Color=Colors.Silver, Name=c.Name}).ToList();
But it´s annoying recreating the object, especially if you have many properties to pass. how to do it simpler?
thanks