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?
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.
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).
Example:
Dim myArray as ObjectArray = new ObjectArray()
myArray.Add(somePerson)
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()
myArray.Add(somePerson)
personVariable = myArray.GetAt(0) <------- Now we do not need type cast here since the instance of the class is strongly typed to Person class.