xsharp.eu • X# syntax for constructor chaining
Page 1 of 1

X# syntax for constructor chaining

Posted: Tue Oct 06, 2020 10:57 am
by pemo18
Hello X# Community,

I would like to use constructor chaining that means one constructor in a class should call another constructor with different arguments.

I found an old post by Robert from 2016.

So is calling Self() still the only option?

I would prefer the C# style like:

Constructor(strDateiname As String) : Self()

But its not urgent since right now I am using a second parameter with a default value.

Kind regards,
Peter

X# syntax for constructor chaining

Posted: Tue Oct 06, 2020 11:04 am
by robert
Peter,
The C# syntax is not allowed.
What we allow is:

Code: Select all

Constructor(strDateiname As String) 
Self()
What you could do (using the ; statement delimiter)

Code: Select all

Constructor(strDateiname As String)  ; Self()



Robert