Nyelv

SectionInformation.IsDeclared Tulajdonság

Definíció

Beolvas egy értéket, amely jelzi, hogy a társított konfigurációs szakasz deklarálva van-e a konfigurációs fájlban.

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

Tulajdonság értéke

trueha ez ConfigurationSection deklarálva van a konfigurációs fájlban; ellenkező esetben. false Az alapértelmezett érték a true.

Példák

Az ebben a szakaszban szereplő példák bemutatják, hogyan szerezheti be a tulajdonság értékét a IsDeclared konfigurációs fájl kapcsolódó szakaszadatainak elérése után.

Az alábbi példa lekéri az SectionInformation objektumot.

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

Az alábbi példa lekéri az IsDeclared értéket.

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

A következőre érvényes: