Hi,
I'm trying to call an external method in the Mathematica, but I do not know how to do it. Do you have any experience with calling generic methods from Mathematica? Generic methods are a powerful tool, but I do not know how to connect them to Mathematica.
There is the fragment of my code in C# (only for information):
namespace SpaceMyClass
{
public class MyClass
{
List<object[]> element;
int elementLen = 0;
public void fillElements()
{
//function for add elements to List
}
public T[] column<T>(int x)
{
T[] res = new T[elementLen];
for (int i = 0; i < elementLen; i++)
{
res[i] = (T)element[i][x];
}
return res;
}
}
}
I would like to convert this C# code into Mathematica:
SpaceMyClass.MyClass form = new SpaceMyClass.MyClass();
form.fillElements();
string[] st = form.column<string>(0);
I tried this code:
Needs["NETLink`"];
InstallNET[];
LoadNETAssembly[NotebookDirectory[]<>"SpaceMyClass.dll"];
form=NETNew["SpaceMyClass.MyClass"];
form@fillElements[];
But I do not know how to rewrite last line to Mathematica:
string[] st = myClass.column<string>(0);
Because the code contains <string> and I can not find in Mathematica help or elsewhere how to do it.
I'll be glad for any ideas on how to keep the generics method and use it in Mathematica