using System.Collections.Generic;
public sealed class LoLQueue<T> where T: class
{
private SingleLinkNode<T> mHe;
private SingleLinkNode<T> mTa;
public LoLQueue()
{
this.mHe = new SingleLinkNode<T>();
this.mTa = this.mHe;
}
}
Error:
The non-generic type 'LoLQueue<T>.SingleLinkNode' cannot be used with type arguments
Why do i get this?
I’m pretty sure you haven’t defined your
SingleLinkNodeclass as having a generic type parameter. As such, an attempt to declare it with one is failing.The error message suggests that
SingleLinkNodeis a nested class, so I suspect what may be happening is that you are declaring members ofSingleLinkNodeof typeT, without actually declaringTas a generic parameter forSingleLinkNode. You still need to do this if you wantSingleLinkNodeto be generic, but if not, then you can simply use the class asSingleLinkNoderather thanSingleLinkNode<T>.Example of what I mean:
If you do want your nested class to be generic, then this will work: