I am trying to initialize a generic class with an object type, however am unable to do it.
Below code will explain what I mean:
PagingList<MyForm> Form = new PagingList<MyForm>();
So PagingList is my generic class and I have assigned the type "MyForm", however am unable to initialize it.
The error is :
"PagingList' does not contain a constructor that takes 0 arguments"
PagingList is a package which I added externally. MyForm is a class which I have created.
How could I initialize this?
Thank you.
To create an instance of the class you need to call a constructor of this class like you do:
new PagingList<MyForm>();
You try to call the default constructor that takes no arguments.
The error you see means that there is no constructor in PagingList class that takes 0 arguments. Check in the object browser if there are other constructors with 1 or more parameters or static methods that instantiates this class.
If you want you can refer to the documentation for more details on constructors: C# Classes Constructors