Export (0) Print
Expand All

MathHelper.Clamp Method

Restricts a value to be within a specified range.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static float Clamp (
         float value,
         float min,
         float max
)

Parameters

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

Return Value

The clamped value.
  • If value > max, max will be returned.
  • If value < min, min will be returned.
  • If minvaluemax, value will be returned.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone

Community Additions

ADD
Show:
© 2014 Microsoft