Answers for "lambda C# select any perform action list call function"

C#
0

lambda C# select any perform action list call function

myList.ForEach(p => myFunc(p));

//or

public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
    foreach(T item in source)
        action(item);
}
Which means you can now do:

myList.Where( ... ).ForEach( ... );

//or

string[] items = (new string[] { "d", "f" }).
    Select(x => new Func<string>(() => { 
        //Do something here...
        Console.WriteLine(x); 
        return x.ToUpper(); 
    }
)).Select(t => t.Invoke()).ToArray<string>();

//or

var functions = (new string[] { "d", "f" }).
       Select(x => new Func<string>(() => { 
          //Do something here...
          Console.WriteLine(x); 
          return x.ToUpper(); 
       }));
string[] items = functions.Select(t => t.Invoke()).ToArray<string>();
Posted by: Guest on June-18-2021

Code answers related to "lambda C# select any perform action list call function"

C# Answers by Framework

Browse Popular Code Answers by Language