Platform::Metadata::RuntimeClassName

在应用于类定义时,请确保私有类从 GetRuntimeClassName 函数返回有效名称。

语法

[Platform::Metadata::RuntimeClassName] name

参数设置

name
Windows 运行时中可见的现有公共类型的名称。

备注

在私有 ref 类上使用此特性指定自定义运行时类型名称并且/或者指定现有名称未满足要求。 指定为类实现的公共接口名称。

示例

下面的示例演示如何使用 特性。 在此示例中,HellowWorldImpl 的运行时类型名称为 Test::Native::MyComponent::IHelloWorld

namespace Test
{
    namespace Native
    {
        namespace MyComponent
        {
            public interface class IHelloWorld
            {
                Platform::String^ SayHello();
            };

            private ref class HelloWorldImpl sealed :[Platform::Metadata::RuntimeClassName] IHelloWorld
            {
            public:
                HelloWorldImpl();
                virtual Platform::String^ SayHello();
            };

            Platform::String^ HelloWorldImpl::SayHello()
            {
                return L"Hello World!";
            }
        }
    }
}

另请参阅

Platform::Metadata 命名空间