ApiInformation.IsPropertyPresent(String, String) 方法

定义

返回 true 或 false 以指示指定类型是否存在 (可写或只读) 的指定属性。

public:
 static bool IsPropertyPresent(Platform::String ^ typeName, Platform::String ^ propertyName);
 static bool IsPropertyPresent(winrt::hstring const& typeName, winrt::hstring const& propertyName);
public static bool IsPropertyPresent(string typeName, string propertyName);
function isPropertyPresent(typeName, propertyName)
Public Shared Function IsPropertyPresent (typeName As String, propertyName As String) As Boolean

参数

typeName
String

Platform::String

winrt::hstring

类型的命名空间限定名称。

propertyName
String

Platform::String

winrt::hstring

属性的名称。

返回

Boolean

bool

如果类型存在指定的属性,则为 True;否则为 false

示例

if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.Devices.Sensors.Accelerometer", "ReadingTransform"))
{
    Debug.WriteLine("Windows.Devices.Sensors.Accelerometer.ReadingTransform property was found");
}
else
{
    Debug.WriteLine("Windows.Devices.Sensors.Accelerometer.ReadingTransform property was NOT found");
}

适用于