207 - 问,C++CX:类型系统:字符串

207 - 问,C++CX:类型系统:字符串

fast pass

String

The value of a String object is an immutable (read-only) sequence of char16 (16-bit Unicode) characters. Because a String object is immutable, assignment of a new string literal to a String variable actually replaces the original String object with a new String object. Concatenation operations involve the destruction of the original String object and the creation of a new object.

207 - 问,C++CX:类型系统:字符串_第1张图片

The String class provides methods and operators for concatenating, comparing strings, and other basic string operations. To perform more extensive string manipulations, use the String::Data() member function to retrieve the value of the String^ object as a const wchar_t*. Then use that value to initialize a std::wstring, which provides rich string handling functions.

Embedded NULLs are removed when the string value is returned by the Data property.

StringReference

In cases where your code receives a string or string literal and just passes it on to another method, you can use a Platform::StringReference^ instead of Platform::String^ to avoid making an extra copy of the string data. In loops and other cases where you are passing large numbers of String^ instances, using StringReference^ can provide better performance. 

参考资料

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh699879.aspx

你可能感兴趣的:(207 - 问,C++CX:类型系统:字符串)