I was evaluating the use of List.ForEach() in C# and ran across this interesting post that evaluates the speed of each. What is interesting is that the List.ForEach() is faster even than a for loop 🙂 And it’s not really even close which is mind boggling.
I’m a huge fan of List, so this will be standard mode of operation.
Meanwhile, I was looking for a way to sum the value of one field in a List.
I have a list of ‘Widgets’, each Widget has a Price. I want to get a total price of the widgets in my list.
Here is an example of something I was working on:
bomberList is a
aircraftList is a
Aircraft ac = aircraftList.Find(delegate(Aircraft a)
return a.ACName == s;
if(ac != null)
ac.IsBomber = true;
I need to set the IsBomber to true for every aircraft that name is matched of bomberList