VB.NET needs Iterators

Just reading through the RSS sample I mentioned in my previous post on the Windows RSS Platform and noticed that they are using one of the new C# features in .NET v2, Iterators.  Anyhow the code snippet I’m referring to is:

public static IEnumerable<IFeed> CommonFeedList(IFeedFolder folder)
      Queue<IFeedFolder> queue = new Queue<IFeedFolder>();
      while (queue.Count > 0)
         IFeedFolder currentFolder = queue.Dequeue();
         foreach (IFeedFolder subfolder in (IFeedsEnum)currentFolder.Subfolders)

         foreach (IFeed feed in (IFeedsEnum)currentFolder.Feeds)
            yield return feed;

While not the most elegant piece of code (especially the explicit call to “DoEvents”) it got me thinking about how I would do this in VB.  The long answer is that you need to code the full iterator yourself.  Please, please, please VB team can we have iterators?

Leave a comment