Share via


SectionInformation.IsDeclarationRequired Proprietà

Definizione

Ottiene un valore che indica se la sezione di configurazione deve essere dichiarata nel file di configurazione.

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

Valore della proprietà

true se nel file di configurazione deve essere dichiarato l'oggetto ConfigurationSection associato; in caso contrario, false.

Esempio

Gli esempi in questa sezione illustrano come ottenere il valore della IsDeclarationRequired proprietà dopo l'accesso alle informazioni della sezione correlate nel file di configurazione.

Nell'esempio seguente viene ottiene l'oggetto 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

Nell'esempio seguente viene restituito il IsDeclarationRequired valore .

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

Si applica a

Vedi anche