Tuesday, June 12, 2007

Convert String* to char* and backwards

To convert String* to char*, use the following:

using namespace System::Runtime::InteropServices;
char* temp;
temp = (char*)(void*)Marshal::StringToHGlobalAnsi(txtBx_MgmtName->Text);

To convert char* to String*, just use the constructor of System::String.

BTW, most data types in .NET has the ToString method.

No comments: