<configSections> 的 <sectionGroup> 元素
定義組態區段的命名空間。
<configuration>
<configSections>
<sectionGroup>
Syntax
<sectionGroup name="section group name">
<!-- Configuration sections -->
</sectionGroup>
屬性
描述 | |
---|---|
name | 必要屬性。 指定正在定義區段群組的名稱。 |
父元素
描述 | |
---|---|
<configSections> 元素 | 包含組態區段和命名空間宣告。 |
子元素
描述 | |
---|---|
<section> | 包含組態區段宣告。 |
備註
宣告區段群組會建立組態區段的容器標籤,並確保其他人所定義的組態區段沒有命名衝突。 您可以在彼此之中巢狀 <sectionGroup> 元素。
範例
下列範例示範如何宣告區段群組,並在區段群組內宣告區段:
<configuration>
<configSections>
<sectionGroup name="mySectionGroup">
<section name="mySection"
type="System.Configuration.NameValueSectionHandler,System" />
</sectionGroup>
</configSections>
<mySectionGroup>
<mySection>
<add key="key1" value="value1" />
</mySection>
</mySectionGroup>
</configuration>
組態檔
應用程式組態檔、電腦組態檔 (Machine.config) 與不在應用程式目錄層級的 Web.config 檔案中,皆可使用此元素。