O'Reilly logo

Sams Teach Yourself C# 5.0 in 24 Hours by Scott J. Dorman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hour 12. Understanding Generics

You have already seen how an object can refer to an instance of any class. This enables you to create classes that operate on any data type. Several significant problems can occur with this approach. By working only with object, there is no way for the class to restrict input to be only of a specific type. To perform meaningful operations on the data, it must be cast from object to a more well-defined type. This not only adds complexity, but also sacrifices type safety at compile time.

Generics in C# solve this problem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required