How to Update Members of a Collection with LINQ -- Visual Studio Magazine
Mon Jul 04 2022 19:42:53 GMT+0000 (Coordinated Universal Time)
Saved by @dhfinch #c# #linq #lambda #extensionmethod
I can write an extension method of my own that will attach itself to any collection that implements the IEnumerable interface. My extension method will, in turn, accept a lambda expression that accepts an object out of the collection. Within my extension method, I can loop through the collection my method has been called from. Within that loop, I'll call the lambda expression that's been passed in to my method, passing the lambda expression each object from the collection. Finally, I can return the updated collection:
https://visualstudiomagazine.com/articles/2019/07/01/updating-linq.aspx
Comments