Convert CString array to System::String
Question
I want to convert CString array to managed code ot send it to C#. For normal CString i did like this,
CString menu = "MENU";
String ^ msg = gcnew String(menu);
Globals1::gwtoolbar->Add(msg);
But now i want to send array of string.i dont know how to do for CString array.
When i gave like this it shows error
CString menu[10];
String[] ^ msg = gcnew String(menu);
How can i convert it?
Solution
Given:
CString menu[10]
To convert to a managed array of String:
#DEFINE MENU_COUNT 10;
array<String^>^ clrMenu = gcnew array<String^>(MENU_COUNT);
for (int i = 0; i < MENU_COUNT; ++i)
{
clrMenu[i] = gcnew String(menu[i]);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow