Class ValueTypeExtensions
Various extensions for value types.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class ValueTypeExtensions
Methods
| Improve this Doc View SourceAdd(IntPtr, IntPtr)
Adds two specified native integers.
Declaration
public static IntPtr Add(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first value to add. |
IntPtr | y | The second value to add. |
Returns
Type | Description |
---|---|
IntPtr | The result of adding |
Add(UIntPtr, UIntPtr)
Adds two specified native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr Add(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first value to add. |
UIntPtr | y | The second value to add. |
Returns
Type | Description |
---|---|
UIntPtr | The result of adding |
AddChecked(IntPtr, IntPtr)
Adds two specified native integers.
Declaration
public static IntPtr AddChecked(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first value to add. |
IntPtr | y | The second value to add. |
Returns
Type | Description |
---|---|
IntPtr | The result of adding |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the IntPtr data type. |
AddChecked(UIntPtr, UIntPtr)
Adds two specified native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr AddChecked(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first value to add. |
UIntPtr | y | The second value to add. |
Returns
Type | Description |
---|---|
UIntPtr | The result of adding |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the UIntPtr data type. |
And(IntPtr, IntPtr)
Computes the bitwise AND of two native integer values.
Declaration
public static IntPtr And(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first operand. |
IntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
IntPtr | The bitwise AND. |
And(UIntPtr, UIntPtr)
Computes the bitwise AND of two native integer values.
Declaration
[CLSCompliant(false)]
public static UIntPtr And(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first operand. |
UIntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
UIntPtr | The bitwise AND. |
Decrement(IntPtr)
Decrements native integer by 1.
Declaration
public static IntPtr Decrement(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to increment. |
Returns
Type | Description |
---|---|
IntPtr | The decremented value. |
Decrement(UIntPtr)
Decrements native integer by 1.
Declaration
[CLSCompliant(false)]
public static UIntPtr Decrement(this UIntPtr value)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to increment. |
Returns
Type | Description |
---|---|
UIntPtr | The decremented value. |
Divide(IntPtr, IntPtr)
Divides two specified native integers.
Declaration
public static IntPtr Divide(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The dividend. |
IntPtr | y | The divisor. |
Returns
Type | Description |
---|---|
IntPtr | The result of dividing |
Exceptions
Type | Condition |
---|---|
DivideByZeroException |
|
Divide(UIntPtr, UIntPtr)
Divides two specified native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr Divide(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The dividend. |
UIntPtr | y | The divisor. |
Returns
Type | Description |
---|---|
UIntPtr | The result of dividing |
EnsureFinite(Double)
Throws ArithmeticException if the value is "not a number" (NaN), positive or negative infinity.
Declaration
public static double EnsureFinite(this double value)
Parameters
Type | Name | Description |
---|---|---|
Double | value | The value to check. |
Returns
Type | Description |
---|---|
Double | The value that is equal to |
Exceptions
Type | Condition |
---|---|
ArithmeticException |
|
EnsureFinite(Single)
Throws ArithmeticException if the value is "not a number" (NaN), positive or negative infinity.
Declaration
public static float EnsureFinite(this float value)
Parameters
Type | Name | Description |
---|---|---|
Single | value | The value to check. |
Returns
Type | Description |
---|---|
Single | The value that is equal to |
Exceptions
Type | Condition |
---|---|
ArithmeticException |
|
GreaterThan(IntPtr, IntPtr)
Determines whether the native integer is greater than the specified value.
Declaration
public static bool GreaterThan(this IntPtr value, IntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to compare with other value. |
IntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
GreaterThan(UIntPtr, UIntPtr)
Determines whether the native integer is greater than the specified value.
Declaration
[CLSCompliant(false)]
public static bool GreaterThan(this UIntPtr value, UIntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to compare with other value. |
UIntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
GreaterThanOrEqual(IntPtr, IntPtr)
Determines whether the native integer is greater than or equal to specified value.
Declaration
public static bool GreaterThanOrEqual(this IntPtr value, IntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to compare with other value. |
IntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
GreaterThanOrEqual(UIntPtr, UIntPtr)
Determines whether the native integer is greater than or equal to specified value.
Declaration
[CLSCompliant(false)]
public static bool GreaterThanOrEqual(this UIntPtr value, UIntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to compare with other value. |
UIntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
Increment(IntPtr)
Increments native integer by 1.
Declaration
public static IntPtr Increment(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to increment. |
Returns
Type | Description |
---|---|
IntPtr | The incremented value. |
Increment(UIntPtr)
Increments native integer by 1.
Declaration
[CLSCompliant(false)]
public static UIntPtr Increment(this UIntPtr value)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to increment. |
Returns
Type | Description |
---|---|
UIntPtr | The incremented value. |
IsOneOf<T>(T, T[])
Checks whether the specified value is equal to one of the specified values.
Declaration
public static bool IsOneOf<T>(this T value, params T[] values)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to compare with other. |
T[] | values | Candidate objects. |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
T | The type of object to compare. |
Remarks
This method uses Equals(T) to check equality between two values.
IsOneOf<T>(T, IEnumerable<T>)
Checks whether the specified value is equal to one of the specified values.
Declaration
public static bool IsOneOf<T>(this T value, IEnumerable<T> values)
where T : struct, IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to compare with other. |
IEnumerable<T> | values | Candidate objects. |
Returns
Type | Description |
---|---|
Boolean | true, if |
Type Parameters
Name | Description |
---|---|
T | The type of object to compare. |
Remarks
This method uses Equals(T) to check equality between two values.
LeftShift(IntPtr, Int32)
Shifts native integer value to the left by a specified number of bits.
Declaration
public static IntPtr LeftShift(this IntPtr value, int bits)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to shift. |
Int32 | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
IntPtr | The modified value. |
LeftShift(IntPtr, IntPtr)
Shifts native integer value to the left by a specified number of bits.
Declaration
public static IntPtr LeftShift(this IntPtr value, IntPtr bits)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to shift. |
IntPtr | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
IntPtr | The modified value. |
LeftShift(UIntPtr, Int32)
Shifts native integer value to the left by a specified number of bits.
Declaration
[CLSCompliant(false)]
public static UIntPtr LeftShift(this UIntPtr value, int bits)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to shift. |
Int32 | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
UIntPtr | The modified value. |
LeftShift(UIntPtr, IntPtr)
Shifts native integer value to the left by a specified number of bits.
Declaration
[CLSCompliant(false)]
public static UIntPtr LeftShift(this UIntPtr value, IntPtr bits)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to shift. |
IntPtr | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
UIntPtr | The modified value. |
LessThan(IntPtr, IntPtr)
Determines whether the native integer is less than the specified value.
Declaration
public static bool LessThan(this IntPtr value, IntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to compare with other value. |
IntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThan(UIntPtr, UIntPtr)
Determines whether the native integer is less than the specified value.
Declaration
[CLSCompliant(false)]
public static bool LessThan(this UIntPtr value, UIntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to compare with other value. |
UIntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThanOrEqual(IntPtr, IntPtr)
Determines whether the native integer is less than or equal to specified value.
Declaration
public static bool LessThanOrEqual(this IntPtr value, IntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to compare with other value. |
IntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThanOrEqual(UIntPtr, UIntPtr)
Determines whether the native integer is less than or equal to specified value.
Declaration
[CLSCompliant(false)]
public static bool LessThanOrEqual(this UIntPtr value, UIntPtr comparand)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to compare with other value. |
UIntPtr | comparand | he value that is compared by value to |
Returns
Type | Description |
---|---|
Boolean | true if |
Multiply(IntPtr, IntPtr)
Multiplies two specified native integers.
Declaration
public static IntPtr Multiply(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first value to multiply. |
IntPtr | y | The second value to mulitply. |
Returns
Type | Description |
---|---|
IntPtr | The result of multiplying |
Multiply(UIntPtr, UIntPtr)
Multiplies two specified native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr Multiply(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first value to multiply. |
UIntPtr | y | The second value to mulitply. |
Returns
Type | Description |
---|---|
UIntPtr | The result of multiplying |
MultiplyChecked(IntPtr, IntPtr)
Multiplies two specified native integers.
Declaration
public static IntPtr MultiplyChecked(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first value to multiply. |
IntPtr | y | The second value to mulitply. |
Returns
Type | Description |
---|---|
IntPtr | The result of multiplying |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the IntPtr data type. |
MultiplyChecked(UIntPtr, UIntPtr)
Multiplies two specified native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr MultiplyChecked(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first value to multiply. |
UIntPtr | y | The second value to mulitply. |
Returns
Type | Description |
---|---|
UIntPtr | The result of multiplying |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the IntPtr data type. |
Negate(IntPtr)
Negates native integer value.
Declaration
public static IntPtr Negate(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to negate. |
Returns
Type | Description |
---|---|
IntPtr | The negated value. |
OnesComplement(IntPtr)
Computes the bitwise complement of native integer value.
Declaration
public static IntPtr OnesComplement(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The operand. |
Returns
Type | Description |
---|---|
IntPtr | The result of bitwise complement. |
OnesComplement(UIntPtr)
Computes the bitwise complement of native integer value.
Declaration
[CLSCompliant(false)]
public static UIntPtr OnesComplement(this UIntPtr value)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The operand. |
Returns
Type | Description |
---|---|
UIntPtr | The result of bitwise complement. |
Or(IntPtr, IntPtr)
Computes the bitwise OR of two native integer values.
Declaration
public static IntPtr Or(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first operand. |
IntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
IntPtr | The bitwise OR. |
Or(UIntPtr, UIntPtr)
Computes the bitwise OR of two native integer values.
Declaration
[CLSCompliant(false)]
public static UIntPtr Or(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first operand. |
UIntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
UIntPtr | The bitwise OR. |
Remainder(IntPtr, IntPtr)
Divides two values and returns the remainder.
Declaration
public static IntPtr Remainder(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The dividend. |
IntPtr | y | The divisor. |
Returns
Type | Description |
---|---|
IntPtr | The remainder. |
Exceptions
Type | Condition |
---|---|
DivideByZeroException |
|
Remainder(UIntPtr, UIntPtr)
Divides two values and returns the remainder.
Declaration
[CLSCompliant(false)]
public static UIntPtr Remainder(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The dividend. |
UIntPtr | y | The divisor. |
Returns
Type | Description |
---|---|
UIntPtr | The remainder. |
Exceptions
Type | Condition |
---|---|
DivideByZeroException |
|
RightShift(IntPtr, Int32)
Shifts native integer value to the right by a specified number of bits.
Declaration
public static IntPtr RightShift(this IntPtr value, int bits)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to shift. |
Int32 | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
IntPtr | The modified value. |
RightShift(IntPtr, IntPtr)
Shifts native integer value to the right by a specified number of bits.
Declaration
public static IntPtr RightShift(this IntPtr value, IntPtr bits)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to shift. |
IntPtr | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
IntPtr | The modified value. |
RightShift(UIntPtr, Int32)
Shifts native integer value to the right by a specified number of bits.
Declaration
[CLSCompliant(false)]
public static UIntPtr RightShift(this UIntPtr value, int bits)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to shift. |
Int32 | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
UIntPtr | The modified value. |
RightShift(UIntPtr, IntPtr)
Shifts native integer value to the right by a specified number of bits.
Declaration
[CLSCompliant(false)]
public static UIntPtr RightShift(this UIntPtr value, IntPtr bits)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to shift. |
IntPtr | bits | The numbers of bits to shift. |
Returns
Type | Description |
---|---|
UIntPtr | The modified value. |
Subtract(IntPtr, IntPtr)
Subtracts two native integers.
Declaration
public static IntPtr Subtract(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The minuend. |
IntPtr | y | The subtrahend. |
Returns
Type | Description |
---|---|
IntPtr | The result of subtracting |
Subtract(UIntPtr, UIntPtr)
Subtracts two native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr Subtract(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The minuend. |
UIntPtr | y | The subtrahend. |
Returns
Type | Description |
---|---|
UIntPtr | The result of subtracting |
SubtractChecked(IntPtr, IntPtr)
Subtracts two native integers.
Declaration
public static IntPtr SubtractChecked(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The minuend. |
IntPtr | y | The subtrahend. |
Returns
Type | Description |
---|---|
IntPtr | The result of subtracting |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the IntPtr data type. |
SubtractChecked(UIntPtr, UIntPtr)
Subtracts two native integers.
Declaration
[CLSCompliant(false)]
public static UIntPtr SubtractChecked(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The minuend. |
UIntPtr | y | The subtrahend. |
Returns
Type | Description |
---|---|
UIntPtr | The result of subtracting |
Exceptions
Type | Condition |
---|---|
OverflowException | The result of an operation is outside the bounds of the UIntPtr data type. |
ToBoolean(Int32)
Declaration
public static bool ToBoolean(this int value)
Parameters
Type | Name | Description |
---|---|---|
Int32 | value | The value to convert. |
Returns
Type | Description |
---|---|
Boolean | true if |
ToByte(Boolean)
Declaration
public static byte ToByte(this bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value | The value to convert. |
Returns
Type | Description |
---|---|
Byte | Byte representation of |
ToInt32(Boolean)
Declaration
public static int ToInt32(this bool value)
Parameters
Type | Name | Description |
---|---|---|
Boolean | value | The value to convert. |
Returns
Type | Description |
---|---|
Int32 | Int32 representation of |
ToIntPtr(UIntPtr)
Declaration
[CLSCompliant(false)]
public static IntPtr ToIntPtr(this UIntPtr value)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to convert. |
Returns
Type | Description |
---|---|
IntPtr | The converted |
ToIntPtrChecked(UIntPtr)
Declaration
[CLSCompliant(false)]
public static IntPtr ToIntPtrChecked(this UIntPtr value)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | value | The value to convert. |
Returns
Type | Description |
---|---|
IntPtr | The converted |
Exceptions
Type | Condition |
---|---|
OverflowException |
|
ToUIntPtr(IntPtr)
Declaration
[CLSCompliant(false)]
public static UIntPtr ToUIntPtr(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to convert. |
Returns
Type | Description |
---|---|
UIntPtr | The converted |
ToUIntPtrChecked(IntPtr)
Declaration
[CLSCompliant(false)]
public static UIntPtr ToUIntPtrChecked(this IntPtr value)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | value | The value to convert. |
Returns
Type | Description |
---|---|
UIntPtr | The converted |
Exceptions
Type | Condition |
---|---|
OverflowException |
|
Truncate(Int64)
Truncates 64-bit signed integer.
Declaration
public static int Truncate(this long value)
Parameters
Type | Name | Description |
---|---|---|
Int64 | value | The value to truncate. |
Returns
Type | Description |
---|---|
Int32 | MaxValue if |
TryGetValue<T>(Nullable<T>, out T)
Attempts to get value from nullable container.
Declaration
public static bool TryGetValue<T>(this T? nullable, out T value)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
Nullable<T> | nullable | Nullable value. |
T | value | Underlying value. |
Returns
Type | Description |
---|---|
Boolean | true if |
Type Parameters
Name | Description |
---|---|
T | The underlying value type of the nullable type. |
Xor(IntPtr, IntPtr)
Computes the bitwise XOR of two native integer values.
Declaration
public static IntPtr Xor(this IntPtr x, IntPtr y)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | x | The first operand. |
IntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
IntPtr | The bitwise XOR. |
Xor(UIntPtr, UIntPtr)
Computes the bitwise XOR of two native integer values.
Declaration
[CLSCompliant(false)]
public static UIntPtr Xor(this UIntPtr x, UIntPtr y)
Parameters
Type | Name | Description |
---|---|---|
UIntPtr | x | The first operand. |
UIntPtr | y | The second operand. |
Returns
Type | Description |
---|---|
UIntPtr | The bitwise XOR. |