I'm pretty sure you haven't defined your SingleLinkNode
class as having a generic type parameter. As such, an attempt to declare it with one is failing.
The error message suggests that SingleLinkNode
is a nested class, so I suspect what may be happening is that you are declaring members of SingleLinkNode
of type T
, without actually declaring T
as a generic parameter for SingleLinkNode
. You still need to do this if you want SingleLinkNode
to be generic, but if not, then you can simply use the class as SingleLinkNode
rather than SingleLinkNode<T>
.
Example of what I mean:
public class Generic<T> where T : class
{
private class Node
{
public T data; // T will be of the type use to construct Generic<T>
}
private Node myNode; // No need for Node<T>
}
If you do want your nested class to be generic, then this will work:
public class Generic<T> where T : class
{
private class Node<U>
{
public U data; // U can be anything
}
private Node<T> myNode; // U will be of type T
}