Bagikan melalui


SectionInformation.IsDeclared Properti

Definisi

Mendapatkan nilai yang menunjukkan apakah bagian konfigurasi terkait dideklarasikan dalam file konfigurasi.

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

Nilai Properti

true jika ini ConfigurationSection dinyatakan dalam file konfigurasi; jika tidak, false. Default adalah true.

Contoh

Contoh di bagian ini menunjukkan cara mendapatkan IsDeclared nilai properti setelah mengakses informasi bagian terkait dalam file konfigurasi.

Contoh berikut mendapatkan SectionInformation objek .

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

Contoh berikut mendapatkan nilainya 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())

Berlaku untuk