SectionInformation.IsDeclarationRequired Свойство

Определение

Возвращает значение, указывающее, должен ли раздел конфигурации быть объявлен в файле конфигурации.

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

Значение свойства

Значение true, если связанный объект ConfigurationSection должен быть объявлен в файле конфигурации; в противном случае — значение false.

Примеры

В примерах в этом разделе показано, как получить IsDeclarationRequired значение свойства после получения сведений о связанном разделе в файле конфигурации.

В следующем примере возвращается 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

В следующем примере возвращается 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())

Применяется к

См. также раздел