13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATIONIt is a compile-time error for an interface to directly or indirectly inherit from itself.The base interfaces of an interface are the explicit base interfaces and their base interfaces. In other words, theset of base interfaces is the complete transitive closure of the explicit base interfaces, their explicit baseinterfaces, and so on. An interface inherits all members of its base interfaces. [Example: In the exampleinterface IControl{void Paint();}interface ITextBox: IControl{void SetText(string text);}interface IListBox: IControl{void SetItems(string[] items);}interface IComboBox: ITextBox, IListBox {}the base interfaces of IComboBox are IControl, ITextBox, and IListBox. In other words, the IComboBoxinterface above inherits members SetText and SetItems as well as Paint. end example]A class or struct that implements an interface also implicitly implements all of the interface’s base interfaces.20.1.3 Interface bodyThe interface-body of an interface defines the members of the interface.interface-body:{ interface-member-declarations opt }20.2 Interface membersThe members of an interface are the members inherited from the base interfaces and the members declared by theinterface itself.interface-member-declarations:interface-member-declarationinterface-member-declarations interface-member-declarationinterface-member-declaration:interface-method-declarationinterface-property-declarationinterface-event-declarationinterface-indexer-declarationAn interface declaration may declare zero or more members. The members of an interface must be methods,properties, events, or indexers. An interface cannot contain constants, fields, operators, instance constructors,destructors, or types, nor can an interface contain static members of any kind.All interface members implicitly have public access. It is a compile-time error for interface member declarationsto include any modifiers. In particular, interface members cannot be declared with the modifiers abstract,public, protected, internal, private, virtual, override, or static.[Example: The examplepublic delegate void StringListEvent(IStringList sender);public interface IStringList{void Add(string s);int Count { get; }event StringListEvent Changed;280

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!