私はC#にかなり慣れていないので、これがばかげた質問であれば許してください。エラーが発生していますが、解決方法がわかりません。Visual Studio 2010 を使用しています。
このコード行
public class GClass1 : KeyedCollection<string, GClass2>
エラーが表示されます
'GClass1' does not implement inherited abstract member 'System.Collections.ObjectModel.KeyedCollection<string,GClass2>.GetKeyForItem(GClass2)'
私が読んだことから、これは継承されたクラスに抽象メンバーを実装することで解決できます
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);
}
ただし、これにより、「型または名前空間名が見つかりませんでした TKey/TItem が見つかりませんでした」というエラーが表示されます。
ヘルプ!