ElementInformation.IsPresent Property

 

Gets a value indicating whether the associated ConfigurationElement object is in the configuration file.

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

Public ReadOnly Property IsPresent As Boolean

Property Value

Type: System.Boolean

true if the associated ConfigurationElement object is in the configuration file; otherwise, false.

The following example shows how to use the IsPresent property.

Public Shared Sub IsElementPresent() 

    ' Get the current configuration file.
    Dim config _
    As System.Configuration.Configuration = _
    ConfigurationManager.OpenExeConfiguration( _
    ConfigurationUserLevel.None)

    ' Get the section.
    Dim section As UrlsSection = _
    CType(config.GetSection("MyUrls"), UrlsSection)

    ' Get the element.
    Dim url As UrlConfigElement = _
    section.Simple

    Dim isPresent As Boolean = _
    url.ElementInformation.IsPresent
    Console.WriteLine("Url element is present? {0}", _
    isPresent.ToString())

End Sub 'IsElementPresent

.NET Framework
Available since 2.0
Return to top
Show: