user347640 user347640 - 2 months ago 5
C# Question

C# I'm getting an error

double dval = 1;

for (int i = 0; i < Cols; i++)
{
k = 0;
dval = 1;
for (int j = Cols - 1; j >= 0; j--)
{
colIndex = (i + j) % 3;
val *= dval[colIndex, k];
k++;
}
det -= dval;
}


I'm getting the error:


Cannot apply indexing with [] to an expression of type 'double' for dval


Help me, it is urgent!

Answer

dval is not an array, so you cannot use it in that way. you should have

double [,] dval = new double[rows, cols];

somewhere in your code, to define the matrix you are trying to use, and then you must have put some data in it.

Which kind of calculation are you trying to do?