I want to create a shared stack
I have a Node class
public class GenericNode<T> where T : class { public T item; public GenericNode<T> next; public GenericNode() { } public GenericNode(T item) { this.item = item; } }
And can use it as
GenericNode<string> node = new GenericNode<string>("one")
But I canβt use it either , for example
GenericNode<int> node = new GenericNode<int>(1)
because int is not a reference type (not a class), and I use where T: class But List is also not a reference type.
How can I fix my problem?
source share