Implement .NET Framework interfaces
|Exam Prep. Guides|
|Exam 70-536 Study Guide|
|Exam 70-536 Preparation Guide: Implement .NET Framework interfaces to cause components to comply with standard contracts. (|
Interface is a core reference for the
interface reference type in the C# language.
An interface is like a specification of a contract. It states what should be achieved but not exactly how the achievements should be met. When your class implements an interface, the complier knows your class accepts the contract. So, the complier will process all the methods defined by that interface. The beauty of this is that a black box definition is formed by the interface, and when multiple classes all implement this interface they become similar to use, making it easier for you—the programmer—to work with those classes.
Note: If your class does not conform to the contract then it will not compile.
.NET Framework interfaces
.NET 2.0 made available generic, type-safe versions of many interfaces. Where available, the generic version should be used to promote type safety. The non-generic versions are still available for backward compatibility.
Visual C# Best Practices
- Begin the name of an interface with a capital
I, as in
ICloneable. The reasons for this are purely historical; but, to do otherwise is considered uncool. The Base Class Library interfaces are named using this convention.
- C# Language Reference: Interface
- Should I use an abstract class or an interface?
- Test for an interface implementation
- Visual Studio: Implementing interfaces