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?
Loading
Sherwin HamidiPosted Feb 7, 2007, 1:19 PM
Ok trying that now....sorry!
TomPosted Feb 7, 2007, 12:45 PM
Sherwin HamidiPosted Feb 7, 2007, 11:53 AM
if this is the correct code, and I'm still not getting the results I'm looking for, then is my array not filled?
this is what I've changed it to.
public static void PrintValues( ArrayList myList )
{
foreach ( Array ray in myList )
Console.Write( " {0}", ray.ToString());
Console.WriteLine();
}
Is this the right approach?
JohnPosted Feb 7, 2007, 7:47 AM
String temp = (string)arrayObject;
TomPosted Feb 7, 2007, 4:45 AM
Hi,
Shoudn't the parameter to the procedure PrintValues() be an ArrayList ?
public static void PrintValues(ArrayList myList)
{
foreach (ArrayList list in myList)
{
foreach (object obj in list)
Console.Write( " {0}", obj );
Console.WriteLine();
}
}