Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do i convert a char to a System::String^?

I have this:

MIDL
System::String^ text;
 text = UART_WriteBuffer[UART_WriteIndexTail].ToString();


where UART_WriteBuffer is a char[] and it contains "at\r". UART_WriteIndexTail ranges from 0 to 2.

I want text to contain "a" after the conversion but it contains "97" the ASCII value of "a" represented as a string.
Posted
Updated 27-Jan-10 5:46am
v3

Easy way to do this is to create String^ from the character array and use the indexer on string.
String^ text = gcnew String(UART_WriteBuffer);
Now you can write text[UART_WriteIndexTail].ToString()
 
Share this answer
 
If you need a single character then you may do
C++
System::String ^ text = gcnew String("");
str += (wchar_t) a[0];

:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900