Using Interfaces

In C#, you can't inherit from multiple base classes at the same time. For example, if Window and Graphics are classes, deriving a class named Menu from them like this is illegal:

public class Menu : Window, Graphics   // Illegal

However, like Java, C# supports Java-style interfaces, which C# treats as a contract, indicating that a class will implement a certain set of properties, methods, events, and/or indexers. Unlike base classes, interfaces don't implement any of their members by providing the actual code for properties, methods, and so on. Interfaces are just specifications for those members, and if your class implements an interface, it must provide code for all the members of that interface. A single class can implement ...

Get Microsoft® Visual C#® .NET 2003 Kick Start now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.