Introducing Generics
Generic types are .NET types that can adapt their behavior to different kind of objects without the need of defining a separate version of the type. In other words, you can implement an only generic type to work with integers, strings, custom reference types, and any other .NET type with a single implementation. Generics offer several advantages:
• Strongly typed programming techniques: Generic objects can hold only the specified type and avoid accidents of handling objects of different types within the same group.
• Better performances: Because Generics enable handling only the specified type, they avoid the need of boxing and unboxing from and to System.Object, and this retains for performance overhead.
• Code reuse: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access