.net - Writing Extension methods with Action / Func / Delegates / Lambda in VB and C# -
At first I could not find my head around the functional / lambda aspects of .NET 3.5. I use these features in LINQ every day, but my problem is understanding the implementation, and what exactly does it mean (long? System.funk, etc etc)
Keeping this in mind, How to get the following:
As an example, I would like an extension method for the list (ak) that sets the properties of all the objects in the list for a fixed value, and the update List (of t) It will be called in such a way:
VB:
List some form of dim list (text box) = (new list (of text box)). Update Extension (function (TCTB) Txtb.Text = "Something") C #:
list & lt; Text box & gt; SomeList = (new list & lt; text box & gt; ()). Update Extension (txtb = & gt; txtb.Text = "something"); How does the extension method look, both in VB and C #?
that is:
& lt; Extension () & gt; _ Public Function Update Extension (TK) (LIKE LIKE LIST OF LIST OF LIST OF BVI SOURCE, BEVIVE ??) LIST (TK) '?? End Function Cheers!
Edit
As many have said, can be achieved above, with more or less, with. But my interest is in understanding anything, like something like. Prakash () has been implemented, that is, I am interested in implementing solutions to the above problem.
In fact, you are here with the Micing and Match Extensions extensions. It is almost like a combination of ForEach and it appears that you want a method that will allow you to modify the elements of a list and return the original enumeration. The following should do the trick for you.
VB.Net
& lt; Extension () & gt; Dell (CR) Next Return Source for each of the IEnumerable (TK) source as the Public Function Update Extension (TK) (i.e., iLearmable (TK), Ever Dell in Action (TK)) End Function C #
Public Fixed IEnumerable & lt; T & gt; Update Extension & lt; T & gt; (This IEnumerable & lt; T & gt; source, verb & lt; T & gt; del) {foreach (in various sources) {del (cur); } Return source; }
Comments
Post a Comment