c# - LINQ side effects -
is possible substitute foreach loop lambda expression in linq (.select))?
list<int> l = {1, 2, 3, 4, 5}; foreach (int in l) console.writeline(i); to:
list<int> l = {1, 2, 3, 4, 5}; l.select(/* print console */);
there no linq equivalent of foreach, although easy implement 1 yourself.
eric lippert gives description here of why not implemented in linq itself.
however, if collection list (which appears in example), can use list.foreach:
mylist.foreach(item => console.writeline(item));
Comments
Post a Comment