Quantcast
Channel: LINQ equivalent of foreach for IEnumerable - Stack Overflow
Viewing all articles
Browse latest Browse all 23

Answer by Mark Seemann for LINQ equivalent of foreach for IEnumerable

$
0
0

As numerous answers already point out, you can easily add such an extension method yourself. However, if you don't want to do that, although I'm not aware of anything like this in the BCL, there's still an option in the System namespace, if you already have a reference to Reactive Extension (and if you don't, you should have):

using System.Reactive.Linq;

items.ToObservable().Subscribe(i => i.DoStuff());

Although the method names are a bit different, the end result is exactly what you're looking for.


Viewing all articles
Browse latest Browse all 23

Trending Articles