Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 218643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:46:14+00:00 2026-05-11T18:46:14+00:00

Firstly I can’t get my head around the functional / Lambda aspects of .NET

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:46:15+00:00Added an answer on May 11, 2026 at 6:46 pm

    Really you’re miking and matching extension methods here. It’s almost a combination of Select and ForEach. It appears you want a method that will allow you to both modify elements of a list and return the original enumeration. The following should do the trick for you.

    VB.Net

    <Extension()> _
    Public Function UpdateExtension(Of T)(ByVal source As IEnumerable(Of T), ByVal del As Action(Of T)) As IEnumerable(Of T)
      For Each cur in source
        del(cur)
      Next
      Return source
    End Function
    

    C#

    public static IEnumerable<T> UpdateExtension<T>(this IEnumerable<T> source, Action<T> del) {
      foreach ( var cur in source ) {
        del(cur);
      }
      return source;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, Real World Haskell , which I am reading, says to never use foldl
Im in the process of trying to get my head round a dvcs such
Firstly, can anyone explain how a state object can be shared when the state
Firstly, Thanks everyone for all your help. I can see the successful completion of
Firstly, how can I have jQuery continuously check the time, and add an id
There are two parts to my question - Firstly we can attach event handlers
Firstly, let me set out what I'd like to do. Assume I have three
Firstly, I'm a newbie to C# and SharePoint, (less than a month's experience) so
So firstly here's my query: ( NOTE:I know SELECT * is bad practice I
I wish to order a table: Firstly by Field1=3 Then by Field2 DESC I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.