• Create Account

Banner advertising on our site currently available from just \$5!

### #Actualysg

Posted 06 May 2013 - 09:09 PM

Hi, this is my code.
public Matrix GetCol (int col)
{
if (col > this.Cols)
{
throw new System.Exception("Can't get column #" + col
+ " because it's greater than the number of columns " + this.Cols
+ ".");
}

double [,] newMatrix = new double[this.Rows, 1];

for (int row = 0; 0 < this.Rows; row++)
{
newMatrix[row, 0] =  // HERE!!!!
this.matrix[row, col];
}

return new Matrix(newMatrix);
}
I traced my code and on the line indicated, I get an System.IndexOutOfRangeException. This... makes zero sense. This is a single-threaded application and this.Rows is not being modified. So why is there an exception in there?

### #1ysg

Posted 06 May 2013 - 09:07 PM

Hi, this is my code.
public Matrix GetCol (int col)
{
if (col > this.Cols)
{
throw new System.Exception("Can't get column #" + col
+ " because it's greater than the number of columns " + this.Cols
+ ".");
}

double [,] newMatrix = new double[this.Rows, 1];

for (int row = 0; 0 < this.Rows; row++)
{
[b]newMatrix[row, 0][/b] =
this.matrix[row, col];
}

return new Matrix(newMatrix);
}
I traced my code and on the boldened line, I get an System.IndexOutOfRangeException. This... makes zero sense. This is a single-threaded application and this.Rows is not being modified. So why is there an exception in there?

PARTNERS