 <p>You are getting it wrong, <a href="https://msdn.microsoft.com/en-us/library/system.linq.enumerable.range(v=vs.100).aspx">Enumerable.Range</a> has second parameter as <code>count</code>, it should be:-</p> <pre><code>if (!Enumerable.Range(settingsAgeFrom, (settingsAgeTo - settingsAgeFrom) + 1) .Contains(age)) </code></pre> <p>So by this, your range will be 18 - 20 instead of 18 - 37 (which your current code is producing).</p>