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.

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)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.