 <p>You must use the Double.IsInfinity() and Double.IsNaN() methods.</p> <pre><code>if (Double.IsInfinity(SampleInterval)) { //TODO } if (Double.IsNaN(SampleInterval)) { //TODO } </code></pre> <p>Don't compare directly to Double.NaN, it will always return false.</p>