enumerators

Concurrency or Performance Benefits of yield return over returning a list

I was wondering if there is any concurrency (now or future), or performance benefit to using yield return over returning a list. See the following examples Processing Method void Page_Load() { foreach(var item in GetPostedItems()) Process(item); } using yield return IEnumerable<string> GetPostedItems() { yield return Item1....

Why does enumerating through a collection throw an exception but looping through its items does not

I was testing out some synchronization constructs and I noticed something that confused me. When I was enumerating through a collection while writing to it at the same time, it threw an exception (this was expected), but when I looped through the collection using a for loop, it did not. Can someone explain this? I thought that a List ...

How do Enumerators work in Ruby 1.9.1?

This question is not about how to use Enumerators in Ruby 1.9.1 but rather im curious how they work. Here is some code: class Bunk def initialize @h = [*1..100] end def each if !block_given? enum_for(:each) else 0.upto(@h.length) { |i| yield @h[i] }...

Why doesn't .NET have a bidirectional enumerator?

It's been asked a couple of times on SO how you can implement a bidirectional enumerator (http://stackoverflow.com/questions/191788/two-directional-list-enumerator-in-net, http://stackoverflow.com/questions/451099/implementing-a-bidirectional-enumerator-in-c). My question is not how (which is trivial for most cases), but why no such type...

Does changing a item field in a Collection while iterating invalidates the collection?

Hi, If do: foreach(var a in col) { a.X = 1; } Will my iterator over the collection become invalid? Thanks ...

F# yield! operator - Implementation and possible C# equivalents

I'm currently learning F# and I really love the yield! (yield-bang) operator. Not only for its name but also for what it does of course. The yield! operator basically allows you to yield all elements of a sequence from a sequence expression. This is useful for composing enumerators. Since I regularly encounter big, complicated enumerato...

What are C# Iterators and Generators, and how could I utilize them

I am a VB.Net developer, kind of newbie in C#, While looking in C# documentation I came through Iterators and Generators, could not fully understand the use, I there anyone who can explain (in vb perceptive; if possible) ...