편집

다음을 통해 공유


ConfigurationPropertyAttribute.IsRequired Property

Definition

Gets or sets a value indicating whether the decorated element property is required.

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

Property Value

true if the property is required; otherwise, false. The default is false.

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