Implement .NET Framework interfaces

Jump to: navigation, search
Exam Prep. Guides
Exam 70-536 Study Guide

1. Types and collections

2. Process, threading,…
3. Embedding features
4. Serialization, I/O
5. .NET Security
6. Interop., reflection,…
7. Global., drawing, text

edit
Exam 70-536 Preparation Guide: Implement .NET Framework interfaces to cause components to comply with standard contracts. (System namespace)


Contents



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.


See also


prevpp.png  nextpp.png
C# Online.NET