Char Strings in CLI Managed Heap


Hi all;


Excuse me for being an idiot, but ...


I am trying to initialize character arrays allocated from the
managed heap (CLI), then access the individual elements within
those arrays. Is there any way that I can do what I am trying
to do without resorting to using String objects?

This is what I have tried, and the associated compilation diagnostics:
===========================================================

Test-01.cpp

wchar_t^ wcstr = gcnew wchar_t { L"zxcasdqwe" };

Test-01.cpp(70) : error C2440: 'initializing' : cannot convert from
'wchar_t *' to 'System::Char ^'
No user-defined-conversion operator available, or
Cannot convert an unmanaged type to a managed type

wchar_t^ wcstr2 = gcnew array<wchar_t> { L"zxcasdqwe" };

Test-01.cpp(71) : error C2440: 'initializing' : cannot convert from
'const wchar_t [10]' to 'wchar_t'
There is no context in which this conversion is possible
Test-01.cpp(71) : error C2440: 'initializing' : cannot convert from
'cli::array<Type> ^' to 'System::Char ^'
with
[
Type=wchar_t
]
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called


char Chstr01[] = { "[str01 string]" };
wchar_t^ wcstr22 = gcnew wchar_t (22);
wchar_t^ wcstr22b = wcstr22;
int ndx, Chstr01_len = strlen (Chstr01);


for (ndx = 0; ndx < Chstr01_len; ndx++)
*wcstr22b++ = Chstr01[ndx];

Test-01.cpp(87) : error C2676: binary '++' : 'System::Char ^' does not define
this operator or a conversion to a type acceptable to the
predefined operator

===========================================================


This is some pretty basic stuff that I've not caught on to.

Any help with this would be greatly appreciated!!!
Topic archived. No new replies allowed.