I want to pass a string array to C which uses ansi
in a test, I tried:
unsafe public int ctstAny1dp(String*[] strOut)
{
private string[] strMyC = {
"abcdef string 1",
"abcdef string 2",
"abcdef string 3",
"abcdef string 4",
"abcdef string 5"},
str2 = { "str2_1", "str2 2" };
// the above will be replaced by some other processing in production
// can't implicitly convert: strOut = strMyC;
for (int i = 0; i < strMyC.GetUpperBound(0); i++)
{
strOut[i] =
((Marshal.StringToHGlobalAnsi(strMyC[i])).ToPointer()); };
return strMyC.GetUpperBound(0) + 1;
}
the above won't compile: Error 1 Cannot implicitly convert type 'void*' to
'string*'. An explicit conversion exists (are you missing a cast?)
D:\data\Ieproj\dotnet\IeStringClass\C#\ieStringCS\ ieStringCS\ieString.cs 99
26 ieStringCS
I thought I am getting a pointer to the string.
Is there a better way