I am attempting to call the following FORTRAN method:
subroutine MYMETHOD(THEARRAY)
with the parameter
CHARACTER*200 :: THEARRAY(2)
This seems simple enough but I ran into trouble because it is an array of character arrays. I have tried several approaches to this including marshaling (which runs in to problems because there are multiple strings.) The best I can come up with is:
[DllImport("theFortranDLL.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void MYMETHOD(THEARRAY);
static void Main(string[] args)
{
StringBuilder[] theArray = new StringBuilder[2];
theArray[0] = new StringBuilder("DataA",200);
theArray[1] = new StringBuilder("DataB",200);
MYMETHOD(theArray);
}
However, this does not work. How would I call such a method from C#? Thanks!