Interface members are the members inherited from its base interfaces and the members declared by the interface itself.
interface-member-declarations:
interface-member-declaration
interface-member-declarations interface-member-declaration
interface-member-declaration:
interface-method-declaration
interface-property-declaration
interface-event-declaration
An interface declaration may declare zero or more members. The members of an interface can be methods, properties, events. An interface declaration cannot contain declarations of constants, fields, operators, constructors, or static members of any kind.
All interface members implicitly have public access level. It is a compile error for interface member declarations to include any modifiers.
An interface declaration creates a new declaration space, and the interface member declarations become members of this declaration space. The following rules apply to interface member declarations:
The name of interface methods must differ from the names of all properties and events declared in this interface. In addition, the method signature must differ from the signatures of all other methods declared in the same interface.
The names of interface properties must differ from the names of all other methods and events declared in the same interface. In addition, the property signature must differ from the signatures of all other properties declared in the same interface.
Event names must differ from the names of all other members declared in the same interface.
The inherited members of the interface are not part of the declaration space of the interface. Thus, a derived interface is allowed to declare a member with the same name as a a base interface member (which in this case hides the inherited member). When this occurs, the derived interface member is said to hide the base interface member. Hiding an inherited member is not considered an error, but it does cause the compiler to issue a warning. To suppress the warning, the declaration of the derived interface member hiding the base member can include the New modifier.
If the New modifier is included in a declaration that does not hide an inherited member, a warning is issued by the compiler. This warning is suppressed by removing the New modifier from the member declaration.
Interface properties are determined as follows.
interface-property-declaration:
attributesopt Property property-name property-indexersopt : type
interface-property-accessors End Property property-nameopt ;
interface-property-accessors:
attributesopt Get ;
attributesopt Set ;
attributesopt Get ; attributesopt Set ;
attributesopt Set ; attributesopt Get ;
property-name:
identifier
Components of the property declaration in an interface mean the same as in a class declaration. Property accessor declarations cannot include a body, thus they consist only of a name.
Interface methods are determined as follows:
interface-method-declaration:
interface-sub-declaration
interface-function-declaration
interface-sub-declaration
attributesopt Sub identifier ( formal-parameter-listopt ) ;
interface-function-declaration
attributesopt Function identifier ( formal-parameter-listopt ) : return-type ;
The method declaration component in an interface has the same meaning as in a class declaration. Interface method declaration cannot have a body, thus it consists only of a name.
Interface events are determined as follows:
interface-event-declaration:
attributesopt Event identifier : type;
Components of the event declaration in an interface mean the same as in a class declaration.
Delegate UserEvent(s: string);
Interface IMyInterface
//Property
Property Item[Index: integer]: integer
Get;
Set;
End Property;
//Methods
Sub Run();
Function Execute(): boolean;
//Event
Event OnUserEvent: UserEvent;
End Interface;
See also: