SectionInformation.IsDeclared 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,指示是否已在配置文件中声明了关联的配置节。
public:
property bool IsDeclared { bool get(); };
public bool IsDeclared { get; }
member this.IsDeclared : bool
Public ReadOnly Property IsDeclared As Boolean
属性值
如果此 ConfigurationSection 已在配置文件中声明,则为 true
;否则为 false
。 默认值为 true
。
示例
本部分中的示例演示如何在访问配置文件中的相关节信息后获取 IsDeclared 属性值。
以下示例获取 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
以下示例获取 IsDeclared 值。
bool declared =
sInfo.IsDeclared;
Console.WriteLine("Section declared?: {0}",
declared.ToString());
Dim declared As Boolean = _
sInfo.IsDeclared
Console.WriteLine("Section declared?: {0}", _
declared.ToString())