Generic Class
What is generic class in C#?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Munesh SharmaPosted May 21, 2014, 12:49 AM
http://www.tutorialspoint.com/csharp/csharp_generics.htm
VulpesPosted May 20, 2014, 4:55 PM
For example System.Collections.Generic.Dictionary
var dict = new Dictionary
creates an instance of this class where the keys are strings and the values are ints.
In effect, K is replaced by string and V is replaced by int, wherever these parameters appear in the definition of the generic class and its members.
It is possible for type parameters to be subject to 'constraints'. For example, if a generic class is defined as follows:
class MyClass
{.....}
then T must be replaced with a type which implements IEnumerable, is a reference type and has a constructor which takes no parameters.