# Math.Clamp 方法

## 重载

 Clamp(UInt64, UInt64, UInt64) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(UInt32, UInt32, UInt32) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(UInt16, UInt16, UInt16) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Single, Single, Single) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(SByte, SByte, SByte) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Int32, Int32, Int32) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Int16, Int16, Int16) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Double, Double, Double) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Decimal, Decimal, Decimal) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Byte, Byte, Byte) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`. Clamp(Int64, Int64, Int64) 返回限制在 `min` 和 `max` 范围内（含首尾）的 `value`。Returns `value` clamped to the inclusive range of `min` and `max`.

## Clamp(UInt64, UInt64, UInt64)

``````public:
static System::UInt64 Clamp(System::UInt64 value, System::UInt64 min, System::UInt64 max);``````
``````[System.CLSCompliant(false)]
public static ulong Clamp (ulong value, ulong min, ulong max);``````
``public static ulong Clamp (ulong value, ulong min, ulong max);``
``````[<System.CLSCompliant(false)>]
static member Clamp : uint64 * uint64 * uint64 -> uint64``````
``static member Clamp : uint64 * uint64 * uint64 -> uint64``
``Public Shared Function Clamp (value As ULong, min As ULong, max As ULong) As ULong``

value
UInt64

min
UInt64

max
UInt64

#### 返回

UInt64

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(UInt32, UInt32, UInt32)

``````public:
static System::UInt32 Clamp(System::UInt32 value, System::UInt32 min, System::UInt32 max);``````
``````[System.CLSCompliant(false)]
public static uint Clamp (uint value, uint min, uint max);``````
``public static uint Clamp (uint value, uint min, uint max);``
``````[<System.CLSCompliant(false)>]
static member Clamp : uint32 * uint32 * uint32 -> uint32``````
``static member Clamp : uint32 * uint32 * uint32 -> uint32``
``Public Shared Function Clamp (value As UInteger, min As UInteger, max As UInteger) As UInteger``

value
UInt32

min
UInt32

max
UInt32

#### 返回

UInt32

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(UInt16, UInt16, UInt16)

``````public:
static System::UInt16 Clamp(System::UInt16 value, System::UInt16 min, System::UInt16 max);``````
``````[System.CLSCompliant(false)]
public static ushort Clamp (ushort value, ushort min, ushort max);``````
``public static ushort Clamp (ushort value, ushort min, ushort max);``
``````[<System.CLSCompliant(false)>]
static member Clamp : uint16 * uint16 * uint16 -> uint16``````
``static member Clamp : uint16 * uint16 * uint16 -> uint16``
``Public Shared Function Clamp (value As UShort, min As UShort, max As UShort) As UShort``

value
UInt16

min
UInt16

max
UInt16

#### 返回

UInt16

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Single, Single, Single)

``````public:
static float Clamp(float value, float min, float max);``````
``public static float Clamp (float value, float min, float max);``
``static member Clamp : single * single * single -> single``
``Public Shared Function Clamp (value As Single, min As Single, max As Single) As Single``

value
Single

min
Single

max
Single

#### 返回

Single

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

- 或 --or- 如果 `value` 等于 NaN，则为 NaNNaN if `value` equals NaN.

## Clamp(SByte, SByte, SByte)

``````public:
static System::SByte Clamp(System::SByte value, System::SByte min, System::SByte max);``````
``````[System.CLSCompliant(false)]
public static sbyte Clamp (sbyte value, sbyte min, sbyte max);``````
``public static sbyte Clamp (sbyte value, sbyte min, sbyte max);``
``````[<System.CLSCompliant(false)>]
static member Clamp : sbyte * sbyte * sbyte -> sbyte``````
``static member Clamp : sbyte * sbyte * sbyte -> sbyte``
``Public Shared Function Clamp (value As SByte, min As SByte, max As SByte) As SByte``

value
SByte

min
SByte

max
SByte

#### 返回

SByte

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Int32, Int32, Int32)

``````public:
static int Clamp(int value, int min, int max);``````
``public static int Clamp (int value, int min, int max);``
``static member Clamp : int * int * int -> int``
``Public Shared Function Clamp (value As Integer, min As Integer, max As Integer) As Integer``

value
Int32

min
Int32

max
Int32

#### 返回

Int32

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Int16, Int16, Int16)

``````public:
static short Clamp(short value, short min, short max);``````
``public static short Clamp (short value, short min, short max);``
``static member Clamp : int16 * int16 * int16 -> int16``
``Public Shared Function Clamp (value As Short, min As Short, max As Short) As Short``

value
Int16

min
Int16

max
Int16

#### 返回

Int16

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Double, Double, Double)

``````public:
static double Clamp(double value, double min, double max);``````
``public static double Clamp (double value, double min, double max);``
``static member Clamp : double * double * double -> double``
``Public Shared Function Clamp (value As Double, min As Double, max As Double) As Double``

value
Double

min
Double

max
Double

#### 返回

Double

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

- 或 --or- 如果 `value` 等于 NaN，则为 NaNNaN if `value` equals NaN.

## Clamp(Decimal, Decimal, Decimal)

``````public:
static System::Decimal Clamp(System::Decimal value, System::Decimal min, System::Decimal max);``````
``public static decimal Clamp (decimal value, decimal min, decimal max);``
``static member Clamp : decimal * decimal * decimal -> decimal``
``Public Shared Function Clamp (value As Decimal, min As Decimal, max As Decimal) As Decimal``

value
Decimal

min
Decimal

max
Decimal

#### 返回

Decimal

- 或 --or- 如果 `value` <`min`，则为 `min``min` if `value` <`min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Byte, Byte, Byte)

``````public:
static System::Byte Clamp(System::Byte value, System::Byte min, System::Byte max);``````
``public static byte Clamp (byte value, byte min, byte max);``
``static member Clamp : byte * byte * byte -> byte``
``Public Shared Function Clamp (value As Byte, min As Byte, max As Byte) As Byte``

value
Byte

min
Byte

max
Byte

#### 返回

Byte

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.

## Clamp(Int64, Int64, Int64)

``````public:
static long Clamp(long value, long min, long max);``````
``public static long Clamp (long value, long min, long max);``
``static member Clamp : int64 * int64 * int64 -> int64``
``Public Shared Function Clamp (value As Long, min As Long, max As Long) As Long``

value
Int64

min
Int64

max
Int64

#### 返回

Int64

- 或 --or- 如果 `value` < `min`，则为 `min``min` if `value` < `min`.

- 或 --or- 如果 `max` < `value`，则为 `max``max` if `max` < `value`.