ElementInformation.IsPresent Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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 bool IsPresent { get; }

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.

static public void IsElementPresent()
{
    // Get the current configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

    // Get the section.
    UrlsSection section =
        (UrlsSection)config.GetSection("MyUrls");

    // Get the element.
    UrlConfigElement url = section.Simple;

    bool isPresent =
        url.ElementInformation.IsPresent;
    Console.WriteLine("Url element is present? {0}",
        isPresent.ToString());


}

.NET Framework
Available since 2.0
Return to top
Show: