Skip to content

Language Guide: Interfaces

rollynoel edited this page Jun 18, 2013 · 2 revisions

Added by Rodrigo B. de Oliveira

Interfaces are introduced thru the interface keyword:

interface IFoo:
   pass

Interface methods don't need to have a body:

interface IUnknown:
    def QueryInterface(id as System.Guid) as object

But if they do it must be empty:

interface IFoodMachine:
    def Spam():
        pass

If a method in a interface does not declare a return type it is assumed to be void since there's no body with a return statement where to infer the type from. Thus the above interface declaration is equivalent to the following one:

interface IFoodMachine:
    def Spam() as void

Interfaces can extend other interfaces:

interface ImALumberjackAndImOk:
    def SleepAllNight()
    def WorkAllDay()
 
interface IWishIdBeenAGirlie(ImALumberjackAndImOk):
    def JustLikeMyDearPappa()

Interfaces can be partial:

partial interface I:
    def Foo()
 
partial interface I:
    def Bar()
 
for member in typeof(I).GetMembers():
    print member.Name
Clone this wiki locally