Skip to Main Content
Sams Teach Yourself C# 5.0 in 24 Hours
book

Sams Teach Yourself C# 5.0 in 24 Hours

by Scott J. Dorman
November 2012
Intermediate to advanced content levelIntermediate to advanced
544 pages
12h 3m
English
Sams
Content preview from Sams Teach Yourself C# 5.0 in 24 Hours

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 ...

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.
Start your free trial

You might also like

Sams Teach Yourself C#™ in 24 Hours

Sams Teach Yourself C#™ in 24 Hours

James Foxall, Wendy Haro-Chun

Publisher Resources

ISBN: 9780133256581Purchase book