title: Adding and retrieving from a KeyedCollection
body: <p>I want to use a KeyedCollection to store a class against a string key value.  I have the following code:</p>
  
  <pre><code>public class MyClass
  {
      public string Key;
      public string Test;
  }
  
  public class MyCollection : KeyedCollection&lt;string, MyClass&gt;
  {
      public MyCollection() : base()
      {
      }
  
      protected override String GetKeyForItem(MyClass cls)
      {
          return cls.Key;
      }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          MyCollection col = new MyCollection();
          col.Add(new MyClass()); // Here is want to specify the string Key Value
      }
  }
  </code></pre>
  
  <p>Can anyone tell me what I’m doing wrong here?  Where do I specify the key value so that I can retrieve by it?</p>