Generics are used for writing type-safe code. No need to cast or boxing/unboxing. For example,
public class MyGenericListwhere T: MyClass { ... }
We can also use "class" keyword in where.
public class MyGenericListwhere T: class { ... }
Generics Example
Dictionary has key/value pairs. Dictionary is an example of Generics. For example,
DictionaryintDict = new Dictionary (); intDict.Add(1,2);
DictionarystrDict = new Dictionary (); strDict.Add("First",new MyClass(){...});