RecommendedAsConfigurableAttribute.RecommendedAsConfigurable 屬性

定義

取得值,表示這個屬性 (Attribute) 繫結的屬性 (Property) 是否可用來做為應用程式設定。

C#
public bool RecommendedAsConfigurable { get; }

屬性值

如果這個屬性 (Attribute) 繫結的屬性 (Property) 可以當做應用程式設定來使用則為 true,否則為 false

範例

下列範例會檢查是否 MyProperty 可繫結。 首先,程式代碼會藉由下列方式 MyProperty 取得 的屬性:

然後程式代碼會將 設定myAttribute為 中的 AttributeCollectionRecommendedAsConfigurableAttribute,並檢查 屬性是否可系結。

C#
// Gets the attributes for the property.
AttributeCollection attributes = 
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

// Checks to see if the property is recommended as configurable.
RecommendedAsConfigurableAttribute myAttribute = 
   (RecommendedAsConfigurableAttribute)attributes[typeof(RecommendedAsConfigurableAttribute)];
if(myAttribute.RecommendedAsConfigurable) {
   // Insert code here.
}

適用於

產品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

另請參閱