Generics in .Net 2.0
A new feature for C# in .Net 2.0 is Generics. Think of Generics as generic Types. An example of how generics are used found at C# Generics is a linked list. If you create your own linked list class you would have to specify the type that the linked list used when you coded it or you would have to use Object then cast the Object to the specific type. With generics you could create the liked list class and it could be used with any type with out having to cast the object before you used it.
Here's a quick example of creating a class using generics
This is how you would instantiate MyClass using generics
A new feature for C# in .Net 2.0 is Generics. Think of Generics as generic Types. An example of how generics are used found at C# Generics is a linked list. If you create your own linked list class you would have to specify the type that the linked list used when you coded it or you would have to use Object then cast the Object to the specific type. With generics you could create the liked list class and it could be used with any type with out having to cast the object before you used it.
Here's a quick example of creating a class using generics
Public class MyClass <T>
{
T data;
}
This is how you would instantiate MyClass using generics
MyClass <int> = new MyClass();
MyClass <myType> = new MyClass();