DefaultValue Property
Collapse the table of content
Expand the table of content

ConfigurationPropertyAttribute.DefaultValue Property

 

Gets or sets the default value for the decorated property.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public object DefaultValue { get; set; }

Property Value

Type: System.Object

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

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;
    }
}

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft