I have this code in ASP.NET form:
bool cont = true;
int i = 0;
while (cont)
{
try
{
JToken token = tempJSON["temperature"]["tool" + i];
temperature.Add(JsonConvert.DeserializeObject<Structures.Temperature>(token.ToString()));
i++;
}
catch(NullReferenceException ex) { pokracovat = false; }
}
return new TemperatureAndState(temperature, state);
After running code, the program raises a NullReferenceException inside try catch. How it is possible. I thought that if an exception is raised in a try block the program will call catch and then continue.
Error: