J
John Rivers
this seemed like an reasonable thing to do:
class TestBase {
public abstract void Blah<T>(LinkedList<T> list) where T : TestBase;
}//class
class Test : TestBase {
LinkedList<Test> list;
LinkedListNode<Test> node;
public override void Blah<T>(LinkedList<T> list) {
list.AddLast(this);
list.AddLast(node);
}//method
}//class
list.AddLast() has two overloads
one accepts T and one accepts LinkedListNode<T>
these are the compile errors:
//this: Error 164 Argument '1': cannot convert from
'GameSpace.GameOne.Test' to 'T'
//node: Error 164 Argument '1': cannot convert from
'System.Collections.Generic.LinkedListNode<GameSpace.GameOne.Test>' to
'T'
I was getting the hang of generics but I can't get my head around this
Can anybody explain?
class TestBase {
public abstract void Blah<T>(LinkedList<T> list) where T : TestBase;
}//class
class Test : TestBase {
LinkedList<Test> list;
LinkedListNode<Test> node;
public override void Blah<T>(LinkedList<T> list) {
list.AddLast(this);
list.AddLast(node);
}//method
}//class
list.AddLast() has two overloads
one accepts T and one accepts LinkedListNode<T>
these are the compile errors:
//this: Error 164 Argument '1': cannot convert from
'GameSpace.GameOne.Test' to 'T'
//node: Error 164 Argument '1': cannot convert from
'System.Collections.Generic.LinkedListNode<GameSpace.GameOne.Test>' to
'T'
I was getting the hang of generics but I can't get my head around this
Can anybody explain?