Configuration.GetSection 方法

定義

傳回組態區段。

多載

GetSection(String)

使用指定的區段路徑傳回組態區段。

GetSection(String, String)

使用指定的區段和位置路徑傳回組態區段。

GetSection(String, Type)

使用指定的區段路徑傳回強型別組態區段。

GetSection(String, Type, String)

使用指定的區段和位置路徑,傳回強型別組態區段。

GetSection(String)

使用指定的區段路徑傳回組態區段。

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath);
member this.GetSection : string -> Microsoft.Web.Administration.ConfigurationSection
Public Function GetSection (sectionPath As String) As ConfigurationSection

參數

sectionPath
String

要傳回之區段的路徑。

傳回

ConfigurationSection 物件。

範例

下列範例會 <moduleProviders> 取得 區段,並顯示 區段中每個專案的名稱。

public void GetGetSection(ServerManager manager)
{
    Configuration config = manager.GetAdministrationConfiguration();
    ConfigurationSection configSection = config.GetSection("moduleProviders");
    ConfigurationElementCollection elementCollection =
        configSection.GetCollection();
    Console.WriteLine("There are " + elementCollection.Count.ToString() +
        " elements in the section.");
    foreach (ConfigurationElement element in elementCollection)
    {
        Console.WriteLine("\t {0}", element.Attributes["name"].Value);
    }
}

備註

組態設定包含在將類似設定群組在一起的區段中,以方便起見。 多 GetSection(String) 載會使用其路徑來擷取組態區段。

適用於

GetSection(String, String)

使用指定的區段和位置路徑傳回組態區段。

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, System::String ^ locationPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, string locationPath);
member this.GetSection : string * string -> Microsoft.Web.Administration.ConfigurationSection
Public Function GetSection (sectionPath As String, locationPath As String) As ConfigurationSection

參數

sectionPath
String

要傳回之區段的路徑。

locationPath
String

要搜尋區段的位置。

傳回

ConfigurationSection 物件。

備註

多載會 GetSection(String, String) 搜尋指定位置中的組態區段。

適用於

GetSection(String, Type)

使用指定的區段路徑傳回強型別組態區段。

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, Type ^ type);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, Type type);
member this.GetSection : string * Type -> Microsoft.Web.Administration.ConfigurationSection

參數

sectionPath
String

要傳回之區段的路徑。

type
Type

表示區段的.NET Framework型別。

傳回

ConfigurationSection 物件。

備註

GetSection(String, Type) 載會在指定的區段路徑中傳回強型別組態區段。

適用於

GetSection(String, Type, String)

使用指定的區段和位置路徑,傳回強型別組態區段。

public:
 Microsoft::Web::Administration::ConfigurationSection ^ GetSection(System::String ^ sectionPath, Type ^ type, System::String ^ locationPath);
public Microsoft.Web.Administration.ConfigurationSection GetSection (string sectionPath, Type type, string locationPath);
member this.GetSection : string * Type * string -> Microsoft.Web.Administration.ConfigurationSection

參數

sectionPath
String

要傳回之區段的路徑。

type
Type

代表區段的.NET Framework類型

locationPath
String

要搜尋區段的位置。

傳回

ConfigurationSection 物件。

備註

GetSection(String, Type, String) 載會傳回指定位置和區段路徑中的強型別組態區段。

適用於