Show / Hide Table of Contents

Struct Number<T>

Represents any primitive numeric type.

Implements
IEquatable<T>
IEquatable<Number<T>>
IComparable<T>
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.ReferenceEquals(Object, Object)
Namespace: DotNext
Assembly: DotNext.Reflection.dll
Syntax
[CLSCompliant(false)]
[BeforeFieldInit(false)]
public struct Number<T> : IEquatable<T>, IEquatable<Number<T>>, IComparable<T> where T : struct, IConvertible, IComparable<T>, IEquatable<T>, IFormattable
Type Parameters
Name Description
T

Primitive numeric type.

Remarks

This type demonstrates how to build concept type using method from type Type<T>.

Constructors

| Improve this Doc View Source

Number(T)

Initializes a new generic numeric value.

Declaration
public Number(T value)
Parameters
Type Name Description
T value

Underlying numeric value.

Methods

| Improve this Doc View Source

Equals(T)

Determines whether this number is equal to another.

Declaration
public bool Equals(T other)
Parameters
Type Name Description
T other

Other number to be compared.

Returns
Type Description
Boolean

true if this number is equal to the given number; otherwise, false.

| Improve this Doc View Source

Equals(Object)

Determines whether this number is equal to the specified number.

Declaration
public override bool Equals(object other)
Parameters
Type Name Description
Object other

The number to compare.

Returns
Type Description
Boolean

true, if two numbers are equal; otherwise, false.

Overrides
ValueType.Equals(Object)
| Improve this Doc View Source

GetHashCode()

Computes hash code of the number.

Declaration
public override int GetHashCode()
Returns
Type Description
Int32

Number hash code.

Overrides
ValueType.GetHashCode()
| Improve this Doc View Source

Parse(String)

Converts the string representation of a number to its typed equivalent.

Declaration
public static Number<T> Parse(string text)
Parameters
Type Name Description
String text

A string containing a number to convert.

Returns
Type Description
Number<T>

Parsed number.

Exceptions
Type Condition
ArgumentNullException

text is null.

FormatException

text is not in the correct format.

| Improve this Doc View Source

ToString()

Converts the number into string.

Declaration
public override string ToString()
Returns
Type Description
String

The textual representation of the number.

Overrides
ValueType.ToString()
| Improve this Doc View Source

TryParse(String, out Number<T>)

Converts the string representation of a number to its typed equivalent.

Declaration
public static bool TryParse(string text, out Number<T> value)
Parameters
Type Name Description
String text

A string containing a number to convert.

Number<T> value

Converted number value.

Returns
Type Description
Boolean

Parsed number.

| Improve this Doc View Source

TryParse(String, NumberStyles, IFormatProvider, out Number<T>)

Converts the string representation of a number to its typed equivalent.

Declaration
public static bool TryParse(string text, NumberStyles styles, IFormatProvider provider, out Number<T> value)
Parameters
Type Name Description
String text

A string containing a number to convert.

NumberStyles styles

Style of the number supplied as a string.

IFormatProvider provider

An object that supplies culture-specific formatting information.

Number<T> value

Converted number value.

Returns
Type Description
Boolean

Parsed number.

Operators

| Improve this Doc View Source

Addition(Number<T>, T)

Arithmetic addition operation.

Declaration
public static Number<T> operator +(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Number<T>

The result of addition.

| Improve this Doc View Source

Division(Number<T>, T)

Arithmetic division operation.

Declaration
public static Number<T> operator /(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Number<T>

The result of division operation.

| Improve this Doc View Source

Equality(Number<T>, T)

Performs equality check.

Declaration
public static bool operator ==(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true, if two numbers are equal; otherwise, false.

| Improve this Doc View Source

GreaterThan(Number<T>, T)

Determines whether the first number is greater than the second number.

Declaration
public static bool operator>(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true if the first number is greater than the second number; otherwise, false.

| Improve this Doc View Source

GreaterThanOrEqual(Number<T>, T)

Determines whether the first number is greater than or equal to the second number.

Declaration
public static bool operator >=(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true if the first number is greater than or equal to the second number; otherwise, false.

| Improve this Doc View Source

Implicit(Number<T> to T)

Converts container instance into the underlying numeric type.

Declaration
public static implicit operator T(Number<T> value)
Parameters
Type Name Description
Number<T> value

The container instance to be converted.

Returns
Type Description
T
| Improve this Doc View Source

Inequality(Number<T>, T)

Performs inequality check.

Declaration
public static bool operator !=(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true, if two numbers are not equal; otherwise, false.

| Improve this Doc View Source

LessThan(Number<T>, T)

Determines whether the first number is less than the second number.

Declaration
public static bool operator <(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true if the first number is less than the second number; otherwise, false.

| Improve this Doc View Source

LessThanOrEqual(Number<T>, T)

Determines whether the first number is less than or equal to the second number.

Declaration
public static bool operator <=(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Boolean

true if the first number is less than or equal to the second number; otherwise, false.

| Improve this Doc View Source

Multiply(Number<T>, T)

Arithmetic multiplication operation.

Declaration
public static Number<T> operator *(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Number<T>

The result of multiplication operation.

| Improve this Doc View Source

Subtraction(Number<T>, T)

Arithmetic subtraction operation.

Declaration
public static Number<T> operator -(Number<T> left, T right)
Parameters
Type Name Description
Number<T> left

The left operand.

T right

The right operand.

Returns
Type Description
Number<T>

The result of subtraction.

| Improve this Doc View Source

UnaryNegation(Number<T>)

Arithmetic unary minus operation.

Declaration
public static Number<T> operator -(Number<T> operand)
Parameters
Type Name Description
Number<T> operand

Unary minus operand.

Returns
Type Description
Number<T>

The result of unary minus operation.

| Improve this Doc View Source

UnaryPlus(Number<T>)

Arithmetic unary plus operation.

Declaration
public static Number<T> operator +(Number<T> operand)
Parameters
Type Name Description
Number<T> operand

Unary plus operand.

Returns
Type Description
Number<T>

The result of unary plus operation.

Explicit Interface Implementations

| Improve this Doc View Source

IComparable<T>.CompareTo(T)

Declaration
int IComparable<T>.CompareTo(T other)
Parameters
Type Name Description
T other
Returns
Type Description
Int32
| Improve this Doc View Source

IEquatable<Number<T>>.Equals(Number<T>)

Declaration
bool IEquatable<Number<T>>.Equals(Number<T> other)
Parameters
Type Name Description
Number<T> other
Returns
Type Description
Boolean

Implements

System.IEquatable<T>
System.IEquatable<T>
System.IComparable<T>

Extension Methods

ValueTypeExtensions.IsOneOf<T>(T, IEnumerable<T>)
ValueTypeExtensions.IsOneOf<T>(T, T[])
Sequence.Skip<TEnumerator, T>(ref TEnumerator, Int32)
ExpressionBuilder.Const<T>(T)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX