What I need is to overload Operator + in C# so I can sum 2 matrixes.
What I have is this function:
public int[,] operator+(int[,] matriz1, int[,] matriz2)
{
int[,] retorno = new int[4, 4];
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
retorno[i, j] = matriz1[i, j] + matriz2[i, j];
}
}
return retorno;
}
When I do this for example (WT, W1, W2 are all int[4,4]):
WT = W1 + W2;
I get an error saying: operator + cannot be applied to operands of type int[,] and int[,], what am I doing wrong and how can I solve it?