How to Share Parameters Between Lambda Expressions

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it’s not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not [...]

  • Share/Bookmark

Tags: , ,

Read Users' Comments (1)

Solving Issues With LINQ Foreach Variables

Can you guess what the output of the following program is? using System; using System.Collections.Generic; namespace Lambda { class Program { static void Main(string[] args) { var strings = new[] {“a”, “b”, “c”}; var actions = CreateActions(strings); actions.ForEach(f => f()); } private static List CreateActions(IEnumerable strings) { var actions = new List(); foreach (var s [...]

  • Share/Bookmark

Tags: ,

Read Users' Comments (0)