|
|
|
|
|
by charlieflowers
4272 days ago
|
|
The ability to use type parameterization to create a type with one or more "holes" in it that is filled in at declaration time. For example, a type that is a List of ints would often have almost exactly the same code as a type that is a List of strings. But without generics, you have to write it twice (or copy/paste, use code generation, etc.) With generics, you say "List<T>", and the compiler makes it work for both List<int> and List<string> (and pretty much any other type you substitute for T). (There are various ways of making it work under the compiler can use under the hood). |
|