SectionInformation.IsDeclarationRequired 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示是否必须在配置文件中声明该配置节。
public:
property bool IsDeclarationRequired { bool get(); };
public bool IsDeclarationRequired { get; }
member this.IsDeclarationRequired : bool
Public ReadOnly Property IsDeclarationRequired As Boolean
属性值
如果必须在配置文件中声明关联的 ConfigurationSection 对象,则为 true
;否则为 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())