Используйте конструктор; например:
const wchar_t* const pStr1 = ...;
System::String^ const str1 = gcnew System::String(pStr1);
const char* const pStr2 = ...;
System::String^ const str2 = gcnew System::String(pStr2);
Если вы используете стандартные строковые классы C ++ (std::wstring
или std::string
), вы можете получить указатель с помощью метода c_str()
. Тогда ваш код может быть
const std::wstring const std_str1 = ...;
System::String^ const str1 = gcnew System::String(std_str1.c_str());
См. System.String и подробное обсуждение здесь .
var base = new Uri("http://stackoverflow.com/a/b/c/d.html");
var relative = new Uri(base, "../e.html"); // http://stackoverflow.com/a/b/e.html