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())