hey guys.
Firstly I can't get my head around the functional / Lambda aspects of .NET 3.5. I use these features everyday in LINQ, but my problem is understanding the implementation, and what they really mean (Lambda? System.Func? etc etc)
With this in mind, how would the following be achieved:
As an example, I'd like to have an Extension method for List(Of T) which sets the properties of all the objects in the List to a certain value, and returns the updated List(Of T). It would be called like this:
VB:
Dim someList As List(Of TextBox) = (New List(Of TextBox)).UpdateExtension(Function(txtb) txtb.Text = "something")
C#:
List<TextBox> someList = (new List<TextBox>()).UpdateExtension(txtb => txtb.Text = "something");
What would the Extension method look like, in both VB and C#?
i.e:
<Extension()> _
Public Function UpdateExtension(Of T)(ByVal source As List(Of T), ByVal predicate As ??) As List(Of T)
'??
End Function
cheers!
EDIT
As many have pointed out, the above can be achieved, more or less, with .ForEach(). But my interest is in understading how something like .ForEach() is implemented, i.e. I'm interested in the implementation of the solution for the above problem.