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");
}

適用於