Übergabe eines String-Arrays von VB6 an C # .net
Wie übergebe ich ein VB6-String-Array [Angenommen, s = Array ("a", "b", "c", "d")] über COM Interop an C # .Net?
Ich habe versucht, die Übergabe des C # -String-Arrays an VB und des VB-String-Arrays an C # wie folgt zu implementieren"Funktion oder Schnittstelle als eingeschränkt markiert oder die Funktion verwendet einen Automatisierungstyp, der in Visual Basic nicht unterstützt wird." . Mein Code unten
C#
public interface ITest
{
string[] GetArray();
void SetArray(string[] arrayVal );
}
public class Test : ITest
{
string[] ITest.GetArray() { //Working fine
string[] stringArray = { "red ", "yellow", "blue" };
return stringArray;
}
}
void ITest.SetArray(string[] arrayVal) //Giving an issue
{
string[] stringArray1 = arrayVal;
}
VB
Dim str As Variant
Debug.Print ".NET server returned: "
For Each str In dotNETServer.GetArray 'dotNETServer=TestServer.Test
Debug.Print str
Next
Dim arr(3) As String
arr(1) = "Pahee"
arr(2) = "Tharani"
arr(3) = "Rathan"
dotNETServer.SetArray (arr) 'This one causing the compile error which I mentioned earlier
Update: ::::::
Wir müssen das Array als Referenz in C # übergeben. Ändern Sie es in der Schnittstelle und Methode
void SetArray(ref string[] arrayVal ); //ref added