0

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?

2
  • this looks more like c++ than c#, no? Commented Mar 17, 2010 at 4:25
  • Might me.Im doing this coding in VC++ only.Im sending data from VC++ to C# dll using in VC++ application. Commented Mar 17, 2010 at 4:34

1 Answer 1

1

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]);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.