Editar

Compartilhar via


ConfigurationPropertyAttribute.DefaultValue Property

Definition

Gets or sets the default value for the decorated property.

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

Property Value

The object representing the default value of the decorated configuration-element property.

Examples

The following example shows how to use the DefaultValue property.

[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

Applies to