我有收藏:
class HashedData : IComparable
{
string key;
public string Key
{
get { return key; }
set { key = value; }
}
string value;
public string Value
{
get { return this.value; }
set { this.value = value; }
}
public int CompareTo(object obj)
{
if (obj is HashedData)
{
HashedData hd = (HashedData)obj;
return this.Key.CompareTo(hd.Key);
}
throw new NotImplementedException("Obiekt nie jest typu HashData");
}
}
以及将此集合用作类型od LinkedList的方法:
public void AddToHashTable(List<LinkedList<HashedData>> tablicaHashujÄ
ca, HashedData data)
{
tablicaHashujaca[this.Hashuj(data.Key)].AddLast(**data**);
}
我有错误:
错误1与“System.Collections.Generic.LinkedList.AddLast(String)”匹配的最佳重载方法具有一些无效参数
错误2参数1:无法从“hashowanie.hasheddata”转换为“string”
但是为什么我不能向LinkedList添加hashdata对象呢?有什么办法吗?