Bagikan melalui


SectionInformation.IsDeclarationRequired Properti

Definisi

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

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

Nilai Properti

true jika objek terkait ConfigurationSection harus dideklarasikan dalam file konfigurasi; jika tidak, false.

Contoh

Contoh di bagian ini menunjukkan cara mendapatkan IsDeclarationRequired 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 IsDeclarationRequired .

bool declRequired = 
    sInfo.IsDeclarationRequired;
Console.WriteLine("Declaration required?: {0}",
    declRequired.ToString());
Dim declRequired As Boolean = _
sInfo.IsDeclarationRequired
Console.WriteLine("Declaration required?: {0}", _
declRequired.ToString())

Berlaku untuk

Lihat juga