Murach's C# 2005
How to work with interfaces and generics

Although a C# class can inherit only one class, it can implement one or more interfaces. So in this chapter, you'll learn how to create and implement a C# interface. You'll also learn how to use generics so you can code your own collections that work like the typed collections from the .NET Framework presented in chapter 8. Along the way, you’ll learn how to work with the generic interfaces that are used with generic collections.

Chapter 15 How to work with interfaces and generics
How to work with interfaces 444
An introduction to interfaces 444
Some of the interfaces defined by the .NET Framework 446
How to create an interface 448
How to implement an interface 450
A Product class that implements the ICloneable interface 452
How to use an interface as a parameter 454
How to work with generics 456
How to code a class that defines a generic collection 456
Some of the generic interfaces defined by the .NET Framework 460
How to implement the IComparable<> interface 462
How to use constraints 464
How to implement the IEnumerable<> interface 466
How to code an interface that uses generics 468




Murach's C#

Learn more about this book

View the table of contents

Add this book to your cart



Our Ironclad Guarantee

First, try our books for 90 days. Then, if you aren't completely convinced that our books are the best ones you've ever used, you can return them for a full refund...no questions asked.