This article is transferred from: http://m.biancheng.net/csharp/90/
Generics is a new syntax introduced by C # 2.0, not syntactic sugar, but 2.0 features provided by the framework upgrade.
When we are programming programs, we often encounter modules with very similar functions, except that they process different data.
But we have no choice but to write multiple methods to deal with different data types.
At this time, then the question is coming, is there a way to use the same method to handle the method of passing in different types of parameters? The emergence of generics is specifically to solve this problem.
Generics are in the System.Collections.Generic namespace and are used to constrain parameter types in classes or methods.
Generics are widely used, including methods, classes, and collections.