Problemer med Objecter
Jeg har et lille problem med følgende kode:public Array Compare(string[,] input1, string[,] input2, string[,] input3)
{
// Array with missmatches
string[,] DiffList = new string[(input1.Length / input1.Rank), 3];
string[,] output = new string[(input1.Length / input1.Rank), 4];
for (int i = 0; i < ((input2.Length / 3)); i++)
{
for (int j = 0; j < (input2.Length / 3); j++)
{
// Check if the site_codes matches
if (input1[i, 0].ToString().ToLower() == input2[j, 0].ToString().ToLower())
{
// Adding the devicename
output[i, 0] = input1[i, 1];
// Adding area code
output[i, 1] = input2[j, 1];
// Adding ip adress
output[i, 2] = input1[i, 2];
}
}
}
for (int i = 0; i < (input1.Length / 2); i++)
{
for (int j = 0; j < (input3.Length / 2); j++)
{
if (input1[i, 0].ToString().ToLower() == input3[j, 1].ToString().ToLower() )
{
// Adding service_class
output[i, 3] = input3[j, 0];
//Console.WriteLine(output[i, 3]);
//Console.WriteLine(output[i, 0]);
//Console.WriteLine(output[i, 1]);
//Console.WriteLine(output[i, 2]);
}
//}
}
}
return output;
}
Compileren brokker sig over "Object reference not set to an instance of an object" i følgende linie kode: "if (input1[i, 0].ToString().ToLower() == input3[j, 1].ToString().ToLower() )"
Jeg kan dog ikke se hvorfor der skal være en object reference når jeg bare skal compare forskellige inputs?
På forhånd tak
