Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.