I would like to clamp a value x to a range [a, b]:
x
[a, b]
x = (x < a) ? a : ((x > b) ? b : x);
This is quite basic
There isn't one in the System.Math namespace.
There is a MathHelper Class where it is available for the XNA game studio if that happens to be what you are doing:
MathHelper