I'm trying to figure out how to return a string value from a C++/CLI method back to unmanaged C++ that calls it. In my current implementation, I have a string stored in a local String ^ variable in a (managed) C++/CLI method that I w/like the method to return back to the unmanaged C++ program that calls it. If using a String ^ variable is not a good choice, what construct/type w/be better? Note, I'm leaving out a part where a C# method returns the string value back to the C++/CLI method as it is not a problem.
I'm using VS2017.
CODE Example - for simplicity, code has been reduced.
Unmanaged C++ -----------------------------
_declspec(dllexport) void GetMyString();
int main()
{
GetMyString();
}
(managed) C++/CLI -------------------------
__declspec(dllexport) String GetMyString()
{
String ^ sValue = "Return this string";
return (sValue);
}
Any help is greatly appreciated. Thanks ahead of time.