I have a VB6 app that uses a C# COM DLL. In managed C++ I can write a function as follows:
array<String^>^ GetAManagedArray()
{
//Do stuff and return a managed array
}
I can then assign the returned managed array to an array in VB6:
Sub MySub()
Dim strArray() As String
strArray = myComObject.GetAManagedArray
End Sub
This works fine in C++, but in C# the System.Array object is abstract and I can't seem to find the managed equivalent to the C++ array<>^. Also, in C# just returning string[] does not work.
What is the managed array equivalent in C#?
EDIT: Here is the exact code I have for the fucntions
The C# COM function:
public string[] OneTwoThree()
{
return new string[] { "1", "2", "3" };
}
The VB6 function:
Private Sub Form_Load()
Dim test As New ComObjectCSharp
Dim strArr(), strTemp As String
strArr = test.OneTwoThree
strTemp = strArr(0) & " " & strArr(1) & " " & strArr(2)
MsgBox strTemp
End Sub
The code fails on the fourth line of the VB6 code with the error "Compile error: Can't assign to array"