MathHelper.Clamp Method (Microsoft.Xna.Framework)

Restricts a value to be within a specified range.

Namespace: Microsoft.Xna.Framework
Assembly: MonoGame.Framework (MonoGame.Framework.dll
  • C#
  • VB
  • F#
public static float Clamp(
	float value, 
	float min, 
	float max

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.


Type: System.Single
The value to clamp.
Type: System.Single
The minimum value. If value is less than min, min will be returned.
Type: System.Single
The maximum value. If value is greater than max, max will be returned.

Return Value

Type: System.Single
The clamped value.
Supported in:

 Windows DirectX Desktop
 Linux Desktop
 Windows OpenGL Desktop