To reproduce the problem write the following lines:
int z = 2;
foreach (var i in izkazi1)
{
if (z == 1)
{
Console.WriteLine(i.VREDNOSTI1);
Console.WriteLine(i.VREDNOSTI2);
z = 3;
}
if (i.VREDNOSTI2.Equals("Podatki so v EUR s centi"))
{
z = 1;
}
}
At the line where I asign to z = 3, vs throws this error 'System.NullReferenceException: 'Object reference not set to an instance of an object.'.
I tried to find a string "Podatki so v EUR s centi", that when found would cause the next iteration to write the data it found and not do it again until it finds the line with the same string again.
Anybody have any clue why this would even happen?