共用方式為


SectionInformation.GetParentSection 方法

定義

取得組態區段,其中包含與這個物件有關聯的組態區段。

public:
 System::Configuration::ConfigurationSection ^ GetParentSection();
public System.Configuration.ConfigurationSection GetParentSection ();
member this.GetParentSection : unit -> System.Configuration.ConfigurationSection
Public Function GetParentSection () As ConfigurationSection

傳回

組態區段,包含與這個 ConfigurationSection 物件關聯的 SectionInformation

例外狀況

此方法是從父區段所叫用 (Invoke)。

範例

下列範例會示範如何使用 GetParentSection 方法。

static public void GetParentSection()
{
    SectionInformation sInfo = 
        GetSectionInformation();

    ConfigurationSection parentSection =
        sInfo.GetParentSection();

    Console.WriteLine("Parent section : {0}",
        parentSection.SectionInformation.Name);
}
Public Shared Sub GetParentSection() 

    Dim sInfo As SectionInformation = _
    GetSectionInformation()
    
    Dim parentSection _
    As ConfigurationSection = _
    sInfo.GetParentSection()
    
    Console.WriteLine("Parent section : {0}", _
    parentSection.SectionInformation.Name)

End Sub

備註

如果這個 ConfigurationSection 物件沒有父區段,方法會 GetParentSection 傳回與 Name 屬性相同的值。

適用於