ps my code for some reason keeps shutting down my computer as well.
Wow that's not supposed to happen. I'd look to other causes unless you mean that your VC# crashes and takes down your PC.
To give you a good clue, here is the proper way to address your for loop:
for (int i = 0; i <= firstArray.GetUpperBound(0); i++)
for (int j = 0; j <= firstArray.GetUpperBound(1); j++)
firstArray[i, j] = ??;
I'll let you fill in the stuff for Random yourself (I can't have all the fun!). You were stepping along the array's "diagonal" (really only covering 6 points since it's not a square matrix)
jonsca
Quantitative Phrenologist
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
Just a fix on jonsca's code:
for (int i = 0; i < firstArray.GetUpperBound(0); i++)
for (int j = 0; j < firstArray.GetUpperBound(1); j++)
firstArray[i, j] = ??;
The less than or equal to comparitor should just be less than, else you'll be reading/writing outside of the arrays bounds :)
Not true, Array.Length returns the number of elements in the array and thus you should use the less than. Array.GetUpperBounds() returns the highest index of the array, so you should use less than or equal. If you make the change you suggest you would skip the last element.
Ryshad
Nearly a Posting Virtuoso
1,307 posts since Aug 2009
Reputation Points: 512
Solved Threads: 246
At the end of your code you have to use something like
Console.ReadKey(); //keep console on screen in debug mode
firstArray.Length is equal to 60 (6x10) so is not strange you would get an index out of bounds exception.
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661