Skip to content

Instantly share code, notes, and snippets.

@nelsonlaquet
Created May 18, 2012 01:40
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 nelsonlaquet/2722635 to your computer and use it in GitHub Desktop.
Save nelsonlaquet/2722635 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ConsoleApplication1
{
interface IItem
{
}
class Key : IItem
{
}
class Inventory : IEnumerable
{
private List<IItem> _items;
public Inventory()
{
_items = new List<IItem>();
}
public void Add(IItem item)
{
if (_items.Contains(item))
throw new InvalidOperationException();
_items.Add(item);
Console.WriteLine("ADDING ITEM!");
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}
class Program
{
static void Main(string[] args)
{
var key = new Key();
var inventory = new Inventory
{
key,
key,
new Key(),
new Key(),
new Key(),
new Key()
};
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment