C# の LinkedList の Find() メソッドは、文字列などに対しては正常に機能しますが、構造体やオブジェクトなどではどのように使用するのでしょうか?
これが私のコードです:
{
LinkedList<Item> TestLinkedList = new LinkedList<Item>();
TestLinkedList.AddFirst(new Item(3, "Head n Shoulders"));
TestLinkedList.AddAfter(TestLinkedList.First, new Item(45, "Dell"));
//Get the 2nd node in the linklist
Item c = new Item(3, "Head n Shoulders");
LinkedListNode<Item> Node2 = TestLinkedList.Find(c);
TestLinkedList.AddAfter((Node2), new Item(32, "Adidas"));
foreach (Item i in TestLinkedList)
{
i.Print();
}
Console.ReadKey();
}
Node2 に対して NULL を返します。一意のハッシュコードなどを使用しないという間違いを犯していますか?