Where can I find the "clamp" function in .NET?
<p>I would like to clamp a value <code>x</code> to a range <code>[a, b]</code>:</p>

<pre><code>x = (x &lt; a) ? a : ((x &gt; b) ? b : x);
</code></pre>

<p>This is quite basic. But I do not see a function "clamp" in the class library - at least not in <code>System.Math</code>.</p>

<p>(For the unaware to "clamp" a value is to make sure that it lies between some maximum and minimum values. If it’s greater than the max value, then it’s replaced by the max, etc.)</p>
