954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to get 1D arrays from matrix.

Hi, I have a matrix. And I need to get 1D arrays from my matrix. For example, I have follow matrix:
123
456
789
So it looks like 3 arrays: 147, 258, 369. But I got "Index out of range exception" in this code:

int[] b = new int[n];
            for (i = 0; i < n; i++)
            {
                b[i] = a[i, n];
                Console.Write(b[i] + " ");
            }
            Console.WriteLine();


Thanx for any help.

Dasharnb777
Newbie Poster
15 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

The last valid element of an array of dimension n is n-1 (line 4, you're trying to access the nth element of that particular row)

jonsca
Quantitative Phrenologist
Team Colleague
5,621 posts since Sep 2009
Reputation Points: 1,165
Solved Threads: 581
 
The last valid element of an array of dimension n is n-1 (line 4, you're trying to access the nth element of that particular row)


Thanx.

Dasharnb777
Newbie Poster
15 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: