Aracılığıyla paylaş


ConfigurationSectionGroupCollection.GetEnumerator Yöntem

Tanım

Nesnede ConfigurationSectionGroupCollection yineleyebilecek bir numaralandırıcı alır.

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
Public Iterator Overrides Function GetEnumerator () As IEnumerator

Döndürülenler

IEnumerator Nesnesi üzerinden ConfigurationSectionGroupCollection yinelemek için kullanılabilecek bir.

Örnekler

Aşağıdaki kod örneğinde yönteminin nasıl kullanılacağı gösterilmektedir GetEnumerator .

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

Şunlara uygulanır

Ayrıca bkz.