List<T> defined as member of class

I have a list where i want the type to be definined by the call for example in the class i want something like

public class ClassName
{
    public ListType<T> ListName { get; set; }
    // other class items
}

and then the usage to be what sets the class type like

var className = new ClassName()
{
    ListType<int> = data
};

so basically thats what i want, i have it working using dynamic so the class is

public class ClassName
{
    public ListType<dynamic> ListName { get; set; }
    // other class items
}

and the call is

var className = new ClassName()
{
    ListType<dynamic> = data
};

this works but i would like to know if there is a better way to do this so i dont have to use dynamic

oh almost forgot to mention the ListType is

public class ListType<T> : List<T>
{
}

and so doesnt fail by having different types passed to it

thanks

edit: realised my usage of the code on stack overflow differed from my code

the ListType has a constructor that takes 3 arguments so the usage is more

var className = new ClassName()
{
    ListName = new ListType<Type>(x, y, z)
}

Answers


How about

public class ClassName<T>
{
    public ListType<T> ListName { get; set; }
    // other class items
}

then use it like this:

var className = new ClassName<int>()
{
    ListName = data;
};

Need Your Help

ng-token-auth not persisting

javascript ruby-on-rails angularjs authentication devise

I have a pretty bare-bones application at the moment using ng-token-auth and rails' devise-token-auth. It is running fine and the $auth methods are working well (for example, logging in). However...