5
Reply

[Newbie] Arraylist Issue...please help

Sherwin Hamidi

Sherwin Hamidi

Feb 6 2007 4:12 PM
2.2k
So I'm new to C#, haven't used C++ in a while and when I did I had the luxury of VS 2003....not anymore....don't ask why, but these are the times I'm in.

So I have an ArrayList which I'm 99% positive is populated correctly in one class -- I passed it to another class with a simple Get and now I'm trying to do nothing but System.Console.Writeline the data in the ArrayList.

Here's the thing -- the ArrayList is composed of many arrays -- each array has n elements so in essence I've created a matrix.  To display this matrix (after defining the ArrayList of course) I've used this simple function which I'm sure everyone has seen before.

public static void PrintValues( IEnumerable myList )
 {
  foreach ( Object obj in myList )
   Console.Write( "   {0}", obj );
  Console.WriteLine();
 }

Here's where my lack of C# knowledge comes in.  The only thing being printed in my Output box at this moment is the first element in the array.....the other n-1 elements are not being printed.  So for each array I'm getting the first element, (so right now 26 individual strings are being printed since I have 26 arrays in my ArrayList) but I need to know how to get access to the other n-1 elements in the individual arrays!  Can anyone help?

Answers (5)