Interface Restrictions Visual C Sharp 2010

Interface Restrictions Visual C Sharp 2010
The essential idea to remember is that an interface never contains any implementation . The
following restrictions are natural consequences of this:

n  You’re not allowed to define any fields in an interface, not even static ones . A field is an
implementation detail of a class or structure .
n  You’re not allowed to define any constructors in an interface . A constructor is also
  considered to be an implementation detail of a class or structure .
n  You’re not allowed to define a destructor in an interface . A destructor contains
the statements used to destroy an object instance .
n  You cannot specify an access modifier for any method . All methods in an interface are
implicitly public .
n  You cannot nest any types (such as enumerations, structures, classes, or interfaces)
  inside an interface .
n  An interface is not allowed to inherit from a structure or a class, although an   interface
can inherit from another interface . Structures and classes contain implementation; if an interface were allowed to inherit from either, it would be inheriting some implementation .

No comments:

Post a Comment