ConfigurationSectionGroupCollection.GetEnumerator ConfigurationSectionGroupCollection.GetEnumerator ConfigurationSectionGroupCollection.GetEnumerator ConfigurationSectionGroupCollection.GetEnumerator Method

Definition

Ruft einen Enumerator ab, der das ConfigurationSectionGroupCollection-Objekt durchlaufen kann.Gets an enumerator that can iterate through the ConfigurationSectionGroupCollection object.

public:
 override System::Collections::IEnumerator ^ GetEnumerator();
public override System.Collections.IEnumerator GetEnumerator ();
override this.GetEnumerator : unit -> System.Collections.IEnumerator
Public Overrides Function GetEnumerator () As IEnumerator

Gibt zurück

Ein IEnumerator, der zum Durchlaufen des ConfigurationSectionGroupCollection-Objekts verwendet werden kann.An IEnumerator that can be used to iterate through the ConfigurationSectionGroupCollection object.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der GetEnumerator-Methode veranschaulicht.The following code example shows how to use the GetEnumerator method.

static void GetEnumerator()
{

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

        ConfigurationSectionGroupCollection groups =
            config.SectionGroups;

        IEnumerator groupEnum =
            groups.GetEnumerator();

        int i = 0;
        while (groupEnum.MoveNext())
        {
            string groupName = groups.GetKey(i);
            Console.WriteLine(
                "Group name: {0}", groupName);
            i += 1;
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub GetEnumerator()
   
   Try
         Dim config _
         As System.Configuration.Configuration = _
         ConfigurationManager.OpenExeConfiguration( _
         ConfigurationUserLevel.None)

         Dim groups _
         As ConfigurationSectionGroupCollection = _
         config.SectionGroups

         Dim groupEnum As IEnumerator = _
         groups.GetEnumerator()
      
      Dim i As Integer = 0
      While groupEnum.MoveNext()
         Dim groupName As String = groups.GetKey(i)
         Console.WriteLine("Group name: {0}", groupName)
         i += 1
      End While

   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub 'GetEnumerator

Gilt für:

Siehe auch