SectionInformation.IsDeclared Свойство

Определение

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

public:
 property bool IsDeclared { bool get(); };
public bool IsDeclared { get; }
member this.IsDeclared : bool
Public ReadOnly Property IsDeclared As Boolean

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

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

Примеры

В примерах в этом разделе показано, как получить IsDeclared значение свойства после получения сведений о связанном разделе в файле конфигурации.

В следующем примере возвращается SectionInformation объект .

// Get the current configuration file.
System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

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

SectionInformation sInfo =
    section.SectionInformation;
' 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)
        
Dim sInfo As SectionInformation = _
section.SectionInformation

В следующем примере возвращается IsDeclared значение .

bool declared =
    sInfo.IsDeclared;
Console.WriteLine("Section declared?: {0}",
    declared.ToString());
Dim declared As Boolean = _
sInfo.IsDeclared
Console.WriteLine("Section declared?: {0}", _
declared.ToString())

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