ConfigurationPropertyAttribute.DefaultValue Właściwość

Definicja

Pobiera lub ustawia wartość domyślną dla właściwości ozdobionej.

public:
 property System::Object ^ DefaultValue { System::Object ^ get(); void set(System::Object ^ value); };
public object DefaultValue { get; set; }
member this.DefaultValue : obj with get, set
Public Property DefaultValue As Object

Wartość właściwości

Obiekt reprezentujący wartość domyślną właściwości dekorowane configuration-element.

Przykłady

W poniższym przykładzie pokazano, jak używać DefaultValue właściwości.

[ConfigurationProperty("url", DefaultValue = "http://www.contoso.com",
    IsRequired = true)]
[RegexStringValidator(@"\w+:\/\/[\w.]+\S*")]
public string Url
{
    get
    {
        return (string)this["url"];
    }
    set
    {
        this["url"] = value;
    }
}
<ConfigurationProperty("url", DefaultValue:="http://www.contoso.com", IsRequired:=True), RegexStringValidator("\w+:\/\/[\w.]+\S*")>
Public Property Url() As String
    Get
        Return CStr(Me("url"))
    End Get
    Set(ByVal value As String)
        Me("url") = value
    End Set
End Property

Dotyczy