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

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -