Convert C# Interface to Xojo

Hello everyone,

I try to translate different C# Projects into Xojo. I found the following Interface Declaration. For me its not possible to translate it 1:1 to Xojo, because you only can initialize empty Method Definitions in a Xojo Interface. Any ideas how to translate?

public interface ITreeData : ITreeNode { int Wide { get; } int High { get; } int ParentConnectLoc { get; } bool Vertical { get; } }

The Interface above could be done with Methods returning Integer/Boolean, but this one?

public interface ITreeNode { bool IsReal { get; set; } }

Everyone who’s interested can find the project I’d like to translate into Xojo here.


Use function definitions :

IsReal() As Boolean
IsReal(Assigns value As Boolean)

It will not be exactly the same but near enough.

Thanks James. And what with that snippet:

public interface NodeExtentProvider<TreeNode>

Looks like an Interface based on a Class. I think this isn’t possible in Xojo.

What you have there Martin is Generics

Xojo does not have support for Generics. So you would need to redesign around it.

Thanks for your answer Björn. Could you please introduce a little bit more?

Not an easy thing to describe in a note. Any chance you are familiar with templates in C++ or Java? It is more or less the same thing. Basically you create templates for classes that the compiler will use later to create the real classes.

You can get around it by building all the classes that are currently implemented in this way.

Lets say you want to create a class that represents ObjectArray…

But then you get the idea that maybe that will not be good since then you will have to type cast the objects as you pull them out of the array all the time. (As in you loose the strongly type type checking and all that).

Dim myArray as ObjectArray = new ObjectArray()


personVariable = Person(myArray.GetAt(0)) <------ notice the type cast here

With Genrics you would do it more like:

So what you then do is make a ObjectArray where T represents that it is anything and will not be defined until creating code to create instance of the class…

Then when you use your class you could do (if Xojo could do this)

Dim myArray as ObjectArray = new ObjectArray()


personVariable = myArray.GetAt(0) <------- Now we do not need type cast here since the instance of the class is strongly typed to Person class.