将char []转换为System :: String ^ [英] Convert char[] to System::String^
本文介绍了将char []转换为System :: String ^的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将字符转换为System :: String ^?
我有这个:
How do i convert a char to a System::String^?
I have this:
System::String^ text;
text = UART_WriteBuffer[UART_WriteIndexTail].ToString();
其中UART_WriteBuffer是char [],并且包含"at \ r". UART_WriteIndexTail的范围是0到2.
我希望文本在转换后包含"a",但它包含以字符串形式表示的"a"的ASCII值"97".
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.
推荐答案
简便的方法这是从字符数组创建String^
并在字符串上使用索引器.
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);
现在,您可以编写text[UART_WriteIndexTail].ToString()
如果需要单个字符,则可以
If you need a single character then you may do
System::String ^ text = gcnew String("");
str += (wchar_t) a[0];
:)
这篇关于将char []转换为System :: String ^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文