Прочитать на английском

Поделиться через


ElementInformation.IsPresent Свойство

Определение

Возвращает значение, указывающее, находится ли связанный объект ConfigurationElement в файле конфигурации.

public bool IsPresent { get; }

Значение свойства

true, если связанный объект ConfigurationElement находится в файле конфигурации, в противном случае — false.

Примеры

В следующем примере показано, как использовать свойство IsPresent.

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

Применяется к