I have a code which reads the temperature values constantly and temperature values will be always negative. How do I write a If condition in C# to check if this temperature falls with in a range of -44 and -46.
I tried with the below code and still the condition passes
if (!Enumerable.Range(-44, 1).Contains(cameraTemp)
|| !Enumerable.Range(-45, 1).Contains(cameraTemp)
|| !Enumerable.Range(-46, 1).Contains(cameraTemp))
I also tried with the below code, but some how still the condition passes
if (!(cameraTemp >= -44 && cameraTemp <= -46))
Though my temperature value is -45, still the condition passes.