The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments

Danpe picture Danpe · Aug 3, 2011 · Viewed 38.9k times · Source
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?

Answer

David Yaw picture David Yaw · Aug 3, 2011

If you want to use IEnumerable<T>, as your post's title suggests, you need to include using System.Collections.Generic;.

As for the SingleLinkNode class, I don't know where you got it, it's not part of the .NET framework that I can see. I'd guess that it isn't implemented using generics, and you'll need to add a bunch of casts from object to T everywhere.