Chapter 17. Introducing generics
After completing this chapter, you will be able to:
Define a type-safe class by using generics.
Implement a generic interface.
Chapter 8 shows you how to use the object type to refer to an instance of any class. You can use the object type to store a value of any type, and you can define parameters by using the object type when you need to pass values of any type into a method. A method can also return values of any type by specifying object as the return type. Although this practice is very flexible, it puts the onus on the programmer to remember what sort of data is actually being used. This can lead to run-time errors if ...
Get Microsoft Visual C# 2013 Step by Step now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.