Simple ForEach Processing on Lists
If you want to process all the items in a list, you can write a For…Each loop…or you can just call the List's ForEach method and pass it a lambda expression containing the processing you want. This code, for example, sets the OrderStatus property on a list of StatusChange objects to Ordered:
Dim statuses As New List(Of StatusChange)
statuses.ForEach(Function(s) s.OrderStatus = "Ordered")
The ForEach method a nice feature. It's a shame more collections don't have it.
Posted by Peter Vogel on 02/16/2015 at 2:20 PM