Math.Clamp 方法

定义

重载

Clamp(UIntPtr, UIntPtr, UIntPtr)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(UInt64, UInt64, UInt64)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(UInt32, UInt32, UInt32)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(UInt16, UInt16, UInt16)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Single, Single, Single)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(SByte, SByte, SByte)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Int64, Int64, Int64)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Int32, Int32, Int32)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Int16, Int16, Int16)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Double, Double, Double)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Decimal, Decimal, Decimal)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(Byte, Byte, Byte)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(IntPtr, IntPtr, IntPtr)

返回限制在 minmax 范围内(含首尾)的 value

Clamp(UIntPtr, UIntPtr, UIntPtr)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

重要

此 API 不符合 CLS。

返回限制在 minmax 范围内(含首尾)的 value

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

参数

value
UIntPtr

nuint

unativeint

要限制的值。

min
UIntPtr

nuint

unativeint

结果的下限。

max
UIntPtr

nuint

unativeint

结果的上限。

返回

UIntPtr

nuint

unativeint

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

属性

适用于

Clamp(UInt64, UInt64, UInt64)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

重要

此 API 不符合 CLS。

返回限制在 minmax 范围内(含首尾)的 value

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);
[<System.CLSCompliant(false)>]
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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

属性

适用于

Clamp(UInt32, UInt32, UInt32)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

重要

此 API 不符合 CLS。

返回限制在 minmax 范围内(含首尾)的 value

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);
[<System.CLSCompliant(false)>]
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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

属性

适用于

Clamp(UInt16, UInt16, UInt16)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

重要

此 API 不符合 CLS。

返回限制在 minmax 范围内(含首尾)的 value

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);
[<System.CLSCompliant(false)>]
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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

属性

适用于

Clamp(Single, Single, Single)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

- 或 -

如果 value 等于 NaN,则为 NaN

适用于

Clamp(SByte, SByte, SByte)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

重要

此 API 不符合 CLS。

返回限制在 minmax 范围内(含首尾)的 value

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);
[<System.CLSCompliant(false)>]
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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

属性

适用于

Clamp(Int64, Int64, Int64)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于

Clamp(Int32, Int32, Int32)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于

Clamp(Int16, Int16, Int16)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于

Clamp(Double, Double, Double)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

- 或 -

如果 value 等于 NaN,则为 NaN

适用于

Clamp(Decimal, Decimal, Decimal)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于

Clamp(Byte, Byte, Byte)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

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

结果的上限。

返回

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于

Clamp(IntPtr, IntPtr, IntPtr)

Source:
Math.cs
Source:
Math.cs
Source:
Math.cs

返回限制在 minmax 范围内(含首尾)的 value

public:
 static IntPtr Clamp(IntPtr value, IntPtr min, IntPtr max);
public static nint Clamp (nint value, nint min, nint max);
public static IntPtr Clamp (IntPtr value, IntPtr min, IntPtr max);
static member Clamp : nativeint * nativeint * nativeint -> nativeint
Public Shared Function Clamp (value As IntPtr, min As IntPtr, max As IntPtr) As IntPtr

参数

value
IntPtr

nint

nativeint

要限制的值。

min
IntPtr

nint

nativeint

结果的下限。

max
IntPtr

nint

nativeint

结果的上限。

返回

IntPtr

nint

nativeint

如果 minvaluemax,则为 value

- 或 -

如果 value<min,则为 min

\- 或 -

如果 max<value,则为 max

适用于