#using <System.dll> using namespace System; int main() { //Two arrays: __wchar_t and String array<__wchar_t^>^ chararray3 = gcnew array<__wchar_t^>(5); array<String^>^ strarray = gcnew array<String^>(5); //values into arrays chararray3[0] = L'\u2550'; chararray3[1] = L'\u2551'; chararray3[2] = L'\u2552'; chararray3[3] = L'\u2553'; chararray3[4] = L'\u2554'; // note: that compiler generates warning C4566 when generating next array "cannot be represented in current code page (1252)" strarray[0] = "\u2550"; strarray[1] = "\u2551"; strarray[2] = "\u2552"; strarray[3] = "\u2553"; strarray[4] = "\u2554"; int cp; // __wchar_t array contents to console ... for(cp=0;cp<5;cp++) { Console::WriteLine(chararray3[cp]); } Console::WriteLine(" "); // space // String array contents to console ... expected result with subbstitution character "?" due to code-page-error/other for(cp=0;cp<5;cp++) { Console::WriteLine(strarray[cp]); } // Question is: why isn't THIS gonna happen ... ???? for(cp=0;cp<5;cp++) { Console::WriteLine((__wchar_t) strarray[cp]); // error C2440 'type cast' : cannot connvert from 'System::String^' to 'wchar_t' !!! } /* wth ... converting on the fly! Why not! It's a string but it's also a literal unicode value identical to the ones contained in the array of __wchar_t that expands to console value without complaint in the above!? */ return 0; }
for(cp=0;cp<5;cp++)
for(cp=0;cp<5;cp++) { Console::WriteLine((System::String ^)strarray[cp]); // error C2440 'type cast' : cannot connvert from 'System::String^' to 'wchar_t' !!! }
string
char
System::String^
Console::WriteLine()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)