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.
This code line
public class GClass1 : KeyedCollection<string, GClass2>
Gives me the error
'GClass1' does not implement inherited abstract member 'System.Collections.ObjectModel.KeyedCollection<string,GClass2>.GetKeyForItem(GClass2)'
From what I've read this can be resolved by implementing the abstract member in the inherited class like so
public class GClass1 : KeyedCollection<string, GClass2>
{
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);
}
However this gives me errors saying 'The type or namespace name could not be found TKey/TItem could not be found.'
Help!