What I want to do must be easy because I can't find it on the web.
I have existing C code with char* strings all over the place. I'd like to get those strings to the Form1.h file so I can use them there. All I want is...
String^ newText;
newText = String(oldCharStarString);

But I get error C2440:
Cannot convert from 'System::String' to 'System::String^'

Why not?

Walt

hi!

you can also try following:

char* ConvertString2Chars ( System::String* strValue)
{
  char* charArray = (char*) System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(strValue).ToPointer();
  return charArray;
}

///
/// convert-function (char* => String)
///
System::String* ConvertChars2String ( const char* charArray )
{
  return charArray;
}

hope this helps

Daniel,
The first suggestin worked. Thank you very much.
And thanks to DaniWeb. No where else on the web could I find the answer.
One small addition. The compiler wanted gcnew instead of new. Like this...
String*newText;
newText = gcnew String(oldCharStarString);

Walt

This question has already been answered. Start a new discussion instead.