Platform::Type 类

包含有关类型的运行时信息,尤其是字符串名称和类型代码。 通过对任何对象调用 Object::GetType 或者对类或结构名称使用 typeid 运算符来获取。

语法

public ref class Platform::Type :
    Platform::Object, Platform::Details::IEquatable,
    Platform::Details::IPrintable

备注

对于必须使用基于对象的运行时类型进行分支的 Typeif 语句来直接处理的应用程序, switch 类非常有用。 描述类型类别的类型代码通过使用 Type::GetTypeCode 成员函数进行检索。

公共方法

名称 描述
Type::GetTypeCode 方法 返回对象的 Platform::TypeCode 枚举 值。
Type::ToString Method 返回在其元数据中指定的类型的名称。

公共属性

名称 描述
Type::FullName 返回表示类型的完全限定名称的 Platform::String 类^,并使用 . (点)而非 ::(双冒号)作为分隔符(如 MyNamespace.MyClass)。

转换运算符

名称 描述
运算符 Type^ 实现从 Windows::UI::Xaml::Interop::TypeNamePlatform::Type的转换。
运算符 Windows::UI::Xaml::Interop::TypeName 实现从 Platform::TypeWindows::UI::Xaml::Interop::TypeName的转换。

要求

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

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

命名空间: Platform

元数据: platform.winmd

Type::FullName 属性

Namespace.Type 形式检索当前类型的完全限定名称。

语法

String^ FullName();

返回值

类型的名称。

示例

//  namespace is TestApp
MainPage::MainPage()
{
    InitializeComponent();
    Type^ t = this->GetType();
    auto s = t->FullName; // returns "TestApp.MainPage"
    auto s2 = t->ToString(); //also returns "TestApp.MainPage"
}

Type::GetTypeCode 方法

检索内置类型数值类型类别。

语法

Platform::TypeCode GetTypeCode();

返回值

Platform::TypeCode 枚举值之一。

注解

GetTypeCode() 成员方法等效于 typeid 属性。

Type::ToString Method

检索类型名称。

语法

Platform::String^ ToString();

返回值

在其元数据中指定的类型的名称。

另请参阅

Platform 命名空间