Learn the essentials of.NET programming in C#. C#: Interfaces and Generics By. Download the files the instructor uses to teach the course. Designing Software with Generics and Reflection in C# ASP.NET.
The most common reasons and use cases for generics are described in the MSDN documentation mentioned before. One benefit of generics I'd like to add is that they can enhance the tool support in the development process. Refactoring tools like those integrated in Visual Studio or ReSharper rely on static type analysis for providing assistance while coding. As generics usually add more type information to your object model, there is more information for such tools to analyse and to help you coding. On a conceptual level, generics help you solving 'cross-cutting' concerns independently from your application domain. Regardless whether you are developing a financial application or a book store, you will sooner or later need to maintain collections of things, be it accounts, books or whatever. The implementation of such collections usually needs to know little to nothing about the things to be maintained in those collections.
Advantages Of Generics In C#
Hence, the generic collections shipped with the.NET framework are a primary example for a generics use case.