Skip to content

Instantly share code, notes, and snippets.

@willmurphyscode
Created August 9, 2017 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willmurphyscode/bbc68f4687fe237e96bb8a90712c8f16 to your computer and use it in GitHub Desktop.
Save willmurphyscode/bbc68f4687fe237e96bb8a90712c8f16 to your computer and use it in GitHub Desktop.
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