ApiInformation.IsReadOnlyPropertyPresent(String, String) 方法

定义

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

public:
 static bool IsReadOnlyPropertyPresent(Platform::String ^ typeName, Platform::String ^ propertyName);
 static bool IsReadOnlyPropertyPresent(winrt::hstring const& typeName, winrt::hstring const& propertyName);
public static bool IsReadOnlyPropertyPresent(string typeName, string propertyName);
function isReadOnlyPropertyPresent(typeName, propertyName)
Public Shared Function IsReadOnlyPropertyPresent (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.IsReadOnlyPropertyPresent("Windows.Devices.Sensors.Accelerometer", "ReadingType"))
{
    Debug.WriteLine("Windows.Devices.Sensors.Accelerometer.ReadingType read-only property was found");
}
else
{
    Debug.WriteLine("Windows.Devices.Sensors.Accelerometer.ReadingType read-only property was NOT found");
}

适用于