Braintique.com header
Left Navigation Bar

Class Interfaces in C#

A class interface is like a kind of contract. If a class implements an interface, it means that it—and any derived classes that inherit from the initial class—must have implementations for the members whose signatures are included in the implementation specification. This means that if you know that a class implements an interface, you know that it implements certain members, and you know what to expect about how those members work—at least in terms of method signatures and member type. (There is, of course, nothing to stop someone from implementing a method specified by an interface as a stub. A method written this way meets the contract specified by the interface—but doesn’t actually do anything.)

In this first part of this article, we’ll take a closer look at class interfaces. How do they compare with abstract base classes, and when should they be used? You'll learn about inspecting a class interface with the Object Browser.

Next, what are some of the most important .NET interfaces? Finally, I’ll show you how to create a class that implements the IComparable interface. (As I’ll explain further, implementing IComparable means that the class must contain a comparison method for ordering objects based on the class.)

In the second part of this article, I’ll show you how to create and implement your own custom class interface.

Previous Table of Contents Next


Google
 
Web www.braintique.com
www.digitalfieldguide.com www.googleplexblog.com


Home | Barticles | Blogs | Books | Services | FAQ | Contact

© Braintique.com. All rights reserved.

Search Engine Optimization







RSS 2.0 Syndication feed

Syndication Viewer

Our Web host:
IX WebHosting



Food for Your Brain! Get a Barticle! Questions Answered Books for You What We Can Do For You Contact Us Brain Food Questions Answered Books for You What We Can Do For You Frequently Asked Questions About Us Google Research Photoshop Wi-Fi and Wireless Networking The Natural Way to Write