method_overloading
This is an old revision of the document!
Method Overloading
Method Overloading is a concept that is not known in VO, but is implemented in the .NET runtime.
It means that you can define multiple methods with the same name in a class. The only difference is that the signature (the parameter list) is different. This is true also for constructors - you can define more than one constructor in a class.
An example:
class MyClass method Foo( cString as string ) as string return cString method Foo( nInt as int ) as string return nInt:ToString() end class
The compiler is able to understand which method to use depending on the parameter type, so this code will use both of the methods:
local oClass as MyClass oClass := MyClass{} oClass:Foo( "Hi guys" ) oClass:Foo( 1234 )
Please note: a different return type is not a different signature, so this will not compile:
method Foo( cString as string ) as string .... method Foo( cString as string ) as int
method_overloading.1516798328.txt.gz · Last modified: 2018/01/24 12:52 by wolfgangriedmann