Changing access modifiers workaround
<p>I'm fairly new to C# so forgive me if this is a stupid question. I'm experiencing an error but I do not know how to resolve it. I'm using Visual Studio 2010. I've already implemented several fixes from community members but problems seem to keep arising.</p>

<p>It started with this code line </p>

<pre><code>public class GClass1 : KeyedCollection&lt;string, GClass2&gt;
</code></pre>

<p>I gave me the error </p>

<pre><code>'GClass1' does not implement inherited abstract member 'System.Collections.ObjectModel.KeyedCollection&lt;string,GClass2&gt;.GetKeyForItem(GClass2)'
</code></pre>

<p>From what I've read this coul be resolved by implementing the abstract member in the inherited class like so</p>

<pre><code>public class GClass1 : KeyedCollection&lt;string, GClass2&gt;
{
  public override TKey GetKeyForItem(TItem item);
  protected override void InsertItem(int index, TItem item)
  {
    TKey keyForItem = this.GetKeyForItem(item);
    if (keyForItem != null)
    {
        this.AddKey(keyForItem, item);
    }
    base.InsertItem(index, item);
}
</code></pre>

<p>However that gave me errors saying 'The type or namespace name could not be found TKey/TItem could not be found.' So I replaced the placeholder types.</p>

<p>Currently the code is </p>

<pre><code>public class GClass1 : KeyedCollection&lt;string, GClass2&gt;
{

  public override string GetKeyForItem(GClass2 item);
  protected override void InsertItem(int index, GClass2 item)
  {
    string keyForItem = this.GetKeyForItem(item);
    if (keyForItem != null)
    {
      this.AddKey(keyForItem, item);
    }
  base.InsertItem(index, item);
 }
</code></pre>

<p>I totally forgot that GetKeyForItem is protected. The new error tells me that I can't change access modifiers when overriding System.Collections.ObjectModel.KeyedCollection.GetKeyForItem(GCl‌​ass2).</p>

<p>I am also getting a strange error saying 'GClass1.GetKeyForItem(GClass2)' must declare a body because it is not marked abstract, extern, or partial'</p>

<p>Are there any workarounds to the access modifier problem, and could someone explain the 'declare a body because it is not marked' error?</p>

<p>Thanks!</p>
