次の方法で共有


ConfigurationPropertyAttribute.IsKey プロパティ

定義

装飾された要素プロパティのキー プロパティかどうかを示す値を取得または設定します。

public:
 property bool IsKey { bool get(); void set(bool value); };
public bool IsKey { get; set; }
member this.IsKey : bool with get, set
Public Property IsKey As Boolean

プロパティ値

true プロパティがコレクションの要素のキー プロパティの場合。それ以外の場合は false。 既定値は、false です。

次の例は、 IsKey プロパティの使用方法を示しています。

[ConfigurationProperty("name", DefaultValue = "Contoso",
    IsRequired = true, IsKey = true)]
public string Name
{
    get
    {
        return (string)this["name"];
    }
    set
    {
        this["name"] = value;
    }
}
<ConfigurationProperty("name", DefaultValue:="Contoso", IsRequired:=True, IsKey:=True)>
Public Property Name() As String
    Get
        Return CStr(Me("name"))
    End Get
    Set(ByVal value As String)
        Me("name") = value
    End Set
End Property

注釈

IsKey プロパティは、装飾するプロパティがコレクションである場合にのみ適用されます。 プロパティがコレクションでない場合は、効果はありません。 複数の要素を IsKeyとしてマークできます。

適用対象