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 3.8.0.1082)
  • C#
  • VB
  • F#
public static int Clamp(
	int value, 
	int min, 
	int max
)

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

Parameters

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

Return Value

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

    
 Windows DirectX Desktop
    
 Linux Desktop
    
 Windows OpenGL Desktop
    
 Web