Platform::StringReference 类

可以用于通过最少复制操作将字符串数据从 Platform::String^ 输入参数传递到其他方法的优化类型。

语法

class StringReference

备注

成员

公共构造函数

名称 描述
StringReference::StringReference 两个用于创建 StringReference实例的构造函数。

公共方法

名称 描述
StringReference::Data 返回 char16 值数组形式的字符串数据。
StringReference::Length 返回字符串中的字符数。
StringReference::GetHSTRING 返回 HSTRING 形式的字符串数据。
StringReference::GetString 返回 Platform::String^形式的字符串数据。

公共运算符

“属性” 描述
StringReference::operator= StringReference 分配给新 StringReference 实例。
StringReference::operator() StringReference 转换为 Platform::String^

要求

支持的最低客户端版本:Windows 8

支持的最低服务器版本:Windows Server 2012

命名空间: Platform

标头: vccorlib.h

StringReference::Data 方法

以 char16 值数组形式返回此 StringReference 的内容。

语法

const ::default::char16 * Data() const;

返回值

char16 UNICODE 文本字符的数组。

StringReference::GetHSTRING 方法

__abi_HSTRING 形式返回字符串内容。

语法

__abi_HSTRING GetHSTRING() const;

返回值

一个包含字符串数据的 __abi_HSTRING

备注

StringReference::GetString 方法

Platform::String^ 形式返回字符串内容。

语法

__declspec(no_release_return) __declspec(no_refcount)
    ::Platform::String^ GetString() const;

返回值

一个包含字符串数据的 Platform::String^

StringReference::Length 方法

返回字符串中的字符数。

语法

unsigned int Length() const;

返回值

指定字符串中字符数的无符号整数。

备注

StringReference::operator= 运算符

将指定对象分配给当前 StringReference 对象。

语法

StringReference& operator=(const StringReference& __fstrArg);
StringReference& operator=(const ::default::char16* __strArg);

参数

__fstrArg
用于初始化当前 StringReference 对象的 StringReference 对象的地址。

__strArg
指向用于初始化当前 StringReference 对象的 char16 值数组的指针。

返回值

对类型为 StringReference 的对象的引用。

备注

由于 StringReference 是标准 C++ 类而不是 ref 类,因此,它不出现在“对象浏览器”中。

StringReference::operator() Operator

StringReference 对象转换为 Platform::String^ 对象。

语法

__declspec(no_release_return) __declspec(no_refcount)
         operator ::Platform::String^() const;

返回值

Platform::String 类型的对象的句柄。

StringReference::StringReference 构造函数

初始化 StringReference 类的新实例。

语法

StringReference();
StringReference(const StringReference& __fstrArg);
StringReference(const ::default::char16* __strArg);
StringReference(const ::default::char16* __strArg, size_t __lenArg);

参数

__fstrArg
其数据用于初始化新实例的 StringReference

__strArg
指向用于初始化新实例的 char16 值数组的指针。

__lenArg
__strArg 中的元素数。

备注

此构造函数的第一个版本是默认构造函数。 第二个版本从 StringReference 参数指定的对象初始化新 __fstrArg 实例类。 第三和第四个重载从 char16 值数组初始化新 StringReference 实例。 char16 表示 16 位 UNICODE 文本字符。

另请参阅

Platform::StringReference 类