다음을 통해 공유


ConfigurationSectionGroupCollection.Item[] 속성

정의

ConfigurationSectionGroup 개체에 있는 ConfigurationSectionGroupCollection 개체를 가져오거나 설정합니다.

오버로드

Item[Int32]

컬렉션에서 지정된 인덱스에 있는 ConfigurationSectionGroup 개체를 가져옵니다.

Item[String]

컬렉션에서 지정된 이름의 ConfigurationSectionGroup 개체를 가져옵니다.

예제

다음 예제에서는 사용 하는 방법에 설명 합니다 Item[] 속성을 반복 하는 합니다 ConfigurationSectionGroupCollection.

static void ShowSectionGroupCollectionInfo(ConfigurationSectionGroupCollection mySectionGroupCollection)
{
    foreach (String mySectionGroupName in mySectionGroupCollection.Keys)
    {
        ConfigurationSectionGroup mySectionGroup = 
            (ConfigurationSectionGroup)mySectionGroupCollection[mySectionGroupName];
        ShowSectionGroupInfo(mySectionGroup);
    }
}
Shared Sub ShowSectionGroupCollectionInfo(mySectionGroupCollection As System.Configuration.ConfigurationSectionGroupCollection)
    Dim mySectionGroupName As String
    For Each mySectionGroupName In  mySectionGroupCollection.Keys
        Dim mySectionGroup As System.Configuration.ConfigurationSectionGroup = CType(mySectionGroupCollection(mySectionGroupName), System.Configuration.ConfigurationSectionGroup)
        ShowSectionGroupInfo(mySectionGroup)
    Next mySectionGroupName
End Sub

Item[Int32]

Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

컬렉션에서 지정된 인덱스에 있는 ConfigurationSectionGroup 개체를 가져옵니다.

public:
 property System::Configuration::ConfigurationSectionGroup ^ default[int] { System::Configuration::ConfigurationSectionGroup ^ get(int index); };
public System.Configuration.ConfigurationSectionGroup this[int index] { get; }
member this.Item(int) : System.Configuration.ConfigurationSectionGroup
Default Public ReadOnly Property Item(index As Integer) As ConfigurationSectionGroup

매개 변수

index
Int32

반환할 ConfigurationSectionGroup 개체의 인덱스입니다.

속성 값

지정된 인덱스의 ConfigurationSectionGroup 개체입니다.

C#에서 이 속성은 ConfigurationSectionCollection 클래스의 인덱서입니다.

적용 대상

Item[String]

Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs
Source:
ConfigurationSectionGroupCollection.cs

컬렉션에서 지정된 이름의 ConfigurationSectionGroup 개체를 가져옵니다.

public:
 property System::Configuration::ConfigurationSectionGroup ^ default[System::String ^] { System::Configuration::ConfigurationSectionGroup ^ get(System::String ^ name); };
public System.Configuration.ConfigurationSectionGroup this[string name] { get; }
member this.Item(string) : System.Configuration.ConfigurationSectionGroup
Default Public ReadOnly Property Item(name As String) As ConfigurationSectionGroup

매개 변수

name
String

반환할 ConfigurationSectionGroup 개체의 이름입니다.

속성 값

지정된 이름을 가진 ConfigurationSectionGroup 개체입니다.

C#에서 이 속성은 ConfigurationSectionCollection 클래스의 인덱서입니다.

예제

다음 코드 예제에서는 Item[] 속성을 사용하는 방법을 보여 줍니다.

static void GetItems()
{

    try
    {
        System.Configuration.Configuration config =
         ConfigurationManager.OpenExeConfiguration(
         ConfigurationUserLevel.None);

        ConfigurationSectionGroupCollection groups =
            config.SectionGroups;

        ConfigurationSectionGroup group1 =
            groups.Get("system.net");

        ConfigurationSectionGroup group2 =
        groups.Get("system.web");

        Console.WriteLine(
             "Group1: {0}", group1.Name);

        Console.WriteLine(
            "Group2: {0}", group2.Name);
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub GetItems()
   
   Try
         Dim config _
     As System.Configuration.Configuration = _
     ConfigurationManager.OpenExeConfiguration( _
     ConfigurationUserLevel.None)

         Dim groups _
         As ConfigurationSectionGroupCollection = _
         config.SectionGroups

         Dim group1 As ConfigurationSectionGroup = _
         groups.Get("system.net")
      
         Dim group2 As ConfigurationSectionGroup = _
         groups.Get("system.web")
      
      
      Console.WriteLine("Group1: {0}", group1.Name)
      
      Console.WriteLine("Group2: {0}", group2.Name)
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub

추가 정보

적용 대상