Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple C# class that implements IEnumerable<T>
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace collections
{
public class Menu : IEnumerable<MenuItem>
{
private List<MenuItem> items;
public Menu(IEnumerable<MenuItem> items)
{
this.items = items.ToList();
}
public IEnumerator<MenuItem> GetEnumerator()
{
return items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.