اقرأ باللغة الإنجليزية تحرير

مشاركة عبر


Math.Clamp Method

Definition

Overloads

Clamp(Single, Single, Single)

Returns value clamped to the inclusive range of min and max.

Clamp(UIntPtr, UIntPtr, UIntPtr)

Returns value clamped to the inclusive range of min and max.

Clamp(UInt64, UInt64, UInt64)

Returns value clamped to the inclusive range of min and max.

Clamp(UInt32, UInt32, UInt32)

Returns value clamped to the inclusive range of min and max.

Clamp(UInt16, UInt16, UInt16)

Returns value clamped to the inclusive range of min and max.

Clamp(SByte, SByte, SByte)

Returns value clamped to the inclusive range of min and max.

Clamp(Int32, Int32, Int32)

Returns value clamped to the inclusive range of min and max.

Clamp(Int64, Int64, Int64)

Returns value clamped to the inclusive range of min and max.

Clamp(Int16, Int16, Int16)

Returns value clamped to the inclusive range of min and max.

Clamp(Double, Double, Double)

Returns value clamped to the inclusive range of min and max.

Clamp(Decimal, Decimal, Decimal)

Returns value clamped to the inclusive range of min and max.

Clamp(Byte, Byte, Byte)

Returns value clamped to the inclusive range of min and max.

Clamp(IntPtr, IntPtr, IntPtr)

Returns value clamped to the inclusive range of min and max.

Clamp(Single, Single, Single)

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

Returns value clamped to the inclusive range of min and max.

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

Parameters

value
Single

The value to be clamped.

min
Single

The lower bound of the result.

max
Single

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

-or-

NaN if value equals NaN.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(UIntPtr, UIntPtr, UIntPtr)

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

Important

This API is not CLS-compliant.

Returns value clamped to the inclusive range of min and 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);

Parameters

value

nuint

The value to be clamped.

min

nuint

The lower bound of the result.

max

nuint

The upper bound of the result.

Returns

nuint

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Attributes

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET 6, 7, 8, 9

Clamp(UInt64, UInt64, UInt64)

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

Important

This API is not CLS-compliant.

Returns value clamped to the inclusive range of min and max.

[System.CLSCompliant(false)]
public static ulong Clamp (ulong value, ulong min, ulong max);

Parameters

value
UInt64

The value to be clamped.

min
UInt64

The lower bound of the result.

max
UInt64

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Attributes

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(UInt32, UInt32, UInt32)

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

Important

This API is not CLS-compliant.

Returns value clamped to the inclusive range of min and max.

[System.CLSCompliant(false)]
public static uint Clamp (uint value, uint min, uint max);

Parameters

value
UInt32

The value to be clamped.

min
UInt32

The lower bound of the result.

max
UInt32

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Attributes

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(UInt16, UInt16, UInt16)

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

Important

This API is not CLS-compliant.

Returns value clamped to the inclusive range of min and max.

[System.CLSCompliant(false)]
public static ushort Clamp (ushort value, ushort min, ushort max);

Parameters

value
UInt16

The value to be clamped.

min
UInt16

The lower bound of the result.

max
UInt16

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Attributes

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(SByte, SByte, SByte)

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

Important

This API is not CLS-compliant.

Returns value clamped to the inclusive range of min and max.

[System.CLSCompliant(false)]
public static sbyte Clamp (sbyte value, sbyte min, sbyte max);

Parameters

value
SByte

The value to be clamped.

min
SByte

The lower bound of the result.

max
SByte

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Attributes

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Int32, Int32, Int32)

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

Returns value clamped to the inclusive range of min and max.

public static int Clamp (int value, int min, int max);

Parameters

value
Int32

The value to be clamped.

min
Int32

The lower bound of the result.

max
Int32

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Int64, Int64, Int64)

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

Returns value clamped to the inclusive range of min and max.

public static long Clamp (long value, long min, long max);

Parameters

value
Int64

The value to be clamped.

min
Int64

The lower bound of the result.

max
Int64

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Int16, Int16, Int16)

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

Returns value clamped to the inclusive range of min and max.

public static short Clamp (short value, short min, short max);

Parameters

value
Int16

The value to be clamped.

min
Int16

The lower bound of the result.

max
Int16

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Double, Double, Double)

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

Returns value clamped to the inclusive range of min and max.

public static double Clamp (double value, double min, double max);

Parameters

value
Double

The value to be clamped.

min
Double

The lower bound of the result.

max
Double

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

-or-

NaN if value equals NaN.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Decimal, Decimal, Decimal)

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

Returns value clamped to the inclusive range of min and max.

public static decimal Clamp (decimal value, decimal min, decimal max);

Parameters

value
Decimal

The value to be clamped.

min
Decimal

The lower bound of the result.

max
Decimal

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value <min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(Byte, Byte, Byte)

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

Returns value clamped to the inclusive range of min and max.

public static byte Clamp (byte value, byte min, byte max);

Parameters

value
Byte

The value to be clamped.

min
Byte

The lower bound of the result.

max
Byte

The upper bound of the result.

Returns

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1

Clamp(IntPtr, IntPtr, IntPtr)

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

Returns value clamped to the inclusive range of min and max.

public static nint Clamp (nint value, nint min, nint max);
public static IntPtr Clamp (IntPtr value, IntPtr min, IntPtr max);

Parameters

value

nint

The value to be clamped.

min

nint

The lower bound of the result.

max

nint

The upper bound of the result.

Returns

nint

value if minvaluemax.

-or-

min if value < min.

-or-

max if max < value.

Applies to

.NET 9 والإصدارات الأخرى
منتج الإصدارات
.NET 6, 7, 8, 9