Freigeben über


SectionInformation.IsDeclared Eigenschaft

Definition

Ruft einen Wert ab, der angibt, ob der zugeordnete Konfigurationsabschnitt in der Konfigurationsdatei deklariert wird.

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

Eigenschaftswert

true wenn dies ConfigurationSection in der Konfigurationsdatei deklariert ist; andernfalls false. Der Standardwert lautet true.

Beispiele

Die Beispiele in diesem Abschnitt zeigen, wie Sie den IsDeclared Eigenschaftswert nach dem Zugriff auf die zugehörigen Abschnittsinformationen in der Konfigurationsdatei abrufen.

Das folgende Beispiel ruft das SectionInformation Objekt ab.

// 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

Im folgenden Beispiel wird der IsDeclared Wert abgerufen.

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

Gilt für: