Class AssignmentUtility
This utility class is designed to make arithmetic assignment operations for numeric operands easier to work with by using generics.
Inheritance
Namespace: Cuemon
Assembly: Cuemon.Core.dll
Syntax
public static class AssignmentUtility
Methods
| Improve this DocAdd<T>(T, T)
Performs a binary addition of the two specified values.
Declaration
public static T Add<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The first value to add. |
T | y | The second value to add. |
Returns
Type | Description |
---|---|
T | The sum of |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
System.OverflowException | The sum of |
And<T>(T, T)
Performs a a bitwise logical conjunction (AND) operation of the two specified values.
Declaration
public static T And<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The first value to AND. |
T | y | The second value to AND. |
Returns
Type | Description |
---|---|
T | The result of |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Assign<T>(T, T)
Performs an assignment of the right-hand operand to the left-hand operand.
Declaration
public static T Assign<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The left-hand operand. |
T | y | The right-hand operand. |
Returns
Type | Description |
---|---|
T | The value of |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Calculate<T>(T, AssignmentOperator, T)
Performs a calculation following the assignment
of the two specified values.
Declaration
public static T Calculate<T>(T x, AssignmentOperator assignment, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The value to calculate with |
AssignmentOperator | assignment | One of the enumeration values that specifies the rules to apply for the assignment operator of |
T | y | The value to calculate with |
Returns
Type | Description |
---|---|
T | The result of the |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Divide<T>(T, T)
Performs a binary division of the two specified values.
Declaration
public static T Divide<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The dividend. |
T | y | The divisor. |
Returns
Type | Description |
---|---|
T | The result of dividing |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
System.DivideByZeroException |
|
System.OverflowException | The sum of |
ExclusiveOr<T>(T, T)
Performs a bitwise exclusive or (XOR) operation of the two specified values.
Declaration
public static T ExclusiveOr<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The first value to XOR. |
T | y | The second value to XOR. |
Returns
Type | Description |
---|---|
T | The result of |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
LeftShift<T>(T, T)
Performs an arithmetic left shift (<<) operation.
Declaration
public static T LeftShift<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The bit pattern to be shifted. |
T | y | The number of bits to shift the bit pattern. |
Returns
Type | Description |
---|---|
T | The result of shifting the bit pattern. |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Multiply<T>(T, T)
Performs a binary multiplication of the two specified values.
Declaration
public static T Multiply<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The multiplicand. |
T | y | The multiplier. |
Returns
Type | Description |
---|---|
T | The result of multiplying |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
System.OverflowException | The sum of |
Or<T>(T, T)
Performs a bitwise logical disjunction (OR) operation of the two specified values.
Declaration
public static T Or<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The first value to OR. |
T | y | The second value to OR. |
Returns
Type | Description |
---|---|
T | The result of |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Remainder<T>(T, T)
Performs a binary division of the two specified values and computes the remainder hereof.
Declaration
public static T Remainder<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The dividend. |
T | y | The divisor. |
Returns
Type | Description |
---|---|
T | The remainder after dividing |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
System.DivideByZeroException |
|
System.OverflowException | The sum of |
RightShift<T>(T, T)
Performs an arithmetic right shift (>>) operation.
Declaration
public static T RightShift<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The bit pattern to be shifted. |
T | y | The number of bits to shift the bit pattern. |
Returns
Type | Description |
---|---|
T | The result of shifting the bit pattern. |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
Subtract<T>(T, T)
Performs a binary subtraction of the two specified values.
Declaration
public static T Subtract<T>(T x, T y)
where T : struct, IConvertible
Parameters
Type | Name | Description |
---|---|---|
T | x | The minuend. |
T | y | The subtrahend. |
Returns
Type | Description |
---|---|
T | The result of subtracting |
Type Parameters
Name | Description |
---|---|
T | The type of the values for the operand operation. |
Exceptions
Type | Condition |
---|---|
TypeArgumentException |
|
System.OverflowException | The sum of |
ValidAsNumericOperand<T>()
Validates if the specified T
is within the allowed range of numeric operands.
Declaration
public static void ValidAsNumericOperand<T>()
where T : struct, IComparable<T>, IEquatable<T>, IConvertible
Type Parameters
Name | Description |
---|---|
T | The type of the value for an operand operation. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException |
|