SectionInformation.IsDeclared Propriedade

Definição

Recebe um valor que indica se a secção de configuração associada está declarada no ficheiro de configuração.

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

Valor de Propriedade

true se isto ConfigurationSection for declarado no ficheiro de configuração; caso contrário, false. A predefinição é true.

Exemplos

Os exemplos nesta secção mostram como obter o valor da IsDeclared propriedade após aceder à informação da secção relacionada no ficheiro de configuração.

O exemplo seguinte obtém o SectionInformation objeto.

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

O exemplo seguinte obtém o IsDeclared valor.

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

Aplica-se a