Can any one tell me how to return a String array from a method and use it in c#?
Suppose i have to return an array of {one,two, .....ten} and in c++ i have to display this array on console and perform some actions.
Can any one tell me how to return a String array from a method and use it in c#?
Suppose i have to return an array of {one,two, .....ten} and in c++ i have to display this array on console and perform some actions.
See here for an example: http://haroonsaeed.wordpress.com/2006/08/11/interop-managed-c-and-c/
not done it my self but at a guess:
in C# create assembly called csharpassembly.dll with the following class
using System;
namespace Csharpassembly {
public class CSharpClass {
public static string[] GetStrings() {
return new string[] {"1", "2", "3"}));
}
}
}
But in your case. Have an assembly that creates the array in c# and havea mC++ program reference this assembly and call it:
#include "stdafx.h"
#using <mscorlib.dll>
#using "csharpassembly.dll"
using namespace System;
using namespace Csharpassembly
__gc class Test {
public:
static void ProcessCShaperStrings() {
array^ stringArray = CSharpClass::GetStrings();
Console::WriteLine(stringArray [0]); ...
// etc
}
};
int wmain(void) {
Test:: ProcessCShaperStrings();
return 0;
}