You want to use generic types in a new project or convert nongeneric types in an existing project to their generic equivalent. However, you do not really know why you would want to do this, and you do not know which nongeneric types should be converted to be generic.
You need to consider several things:
- Will you type contain or be operating on various on unspecified data types? If so, creating a generic tyep will offer several benefits over creating a nongeneric type. If your type will operate on only a single specific type, then you may not need to create a generic type.
- If your type will be operating on value types, so that boxing and unboxing operations will occur, you should consider using generics to prevent the boxing and unboxing operations.
- The stronger type checking associated with generic will aid in finding erros sooner, thus shortening your bug-fixing cycle.
- Is your conde suffering from "code bloat" with you writing multiple classess to handle diffrent data types on which they operate? It is easier to write the code once and have it just work for each of the data type it operates on.
- Generics allow for greater clarity of code. By eliminating code bloat and forcing stronger type checking on your types, your code will be easier to read and understantd.
See Also: See the "Generics Overviews" and "Benefits of Generics" topics in the MSDN documentation.