0 Replies - 155 Views - Last Post: 30 December 2007 - 08:47 PM

#1 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Enumerate an array with IEnumerator

Posted 30 December 2007 - 08:47 PM

Description: Pass the method your multidimensional string arrayThis is a snippet used to enumerate a multidimensional array with the IEnumerator Interface's GetEnumerator Method. There are many ways this can be implemented, for ease of showing this was in a console app
//Namespace Reference
using System;
using System.Collections;


/// 
/// method to enumerate the values of a multidimensional array
/// 
/// array to enumerate
public void EnumerateArray(string[,] arry)
{
    Console.Write("Array elements = ");
    IEnumerator arryEnum = arry.GetEnumerator();
    while (arryEnum.MoveNext())
    {
        Console.Write("{0}, ", arryEnum.Current);
    }
    Console.WriteLine();
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1