CTS Interface Types
Interfaces are nothing more than a named collection of abstract member definitions, which may be
supported (i.e., implemented) by a given class or structure. Unlike COM, .NET interfaces do
not
derive a common base interface such as IUnknown. In C#, interface types are defined using the
interface keyword, for example:
// A C# interface type is usually
// declared as public, to allow types in other
// assemblies to implement their behavior.
public interface IDraw
{
void Draw();
}
On their own, interfaces are of little use. However, when a class or structure implements a given
interface in its unique way, you are able to request access to the supplied functionality using an
interface reference in a polymorphic manner. Interface-based programming will be fully explored
in Chapter 9.
Do'stlaringiz bilan baham: |