UBinarySize Structure

Represents an unsigned quantity of bytes, supporting formatting and parsing using units with binary prefixes such as "KB" or "KiB".

Definition

Namespace: Ookii
Assembly: Ookii.BinarySize (in Ookii.BinarySize.dll) Version: 1.2.0+20f0bdf981c7baf115c68ccab612b1a031efcb4d
C#
[SerializableAttribute]
[TypeConverterAttribute(typeof(UBinarySizeConverter))]
public readonly struct UBinarySize : IEquatable<UBinarySize>, 
	IComparable<UBinarySize>, IComparable, IFormattable, IXmlSerializable, 
	ISpanFormattable, ISpanParsable<UBinarySize>, IParsable<UBinarySize>, 
	IBinaryNumber<UBinarySize>, IAdditionOperators<UBinarySize, UBinarySize, UBinarySize>, 
	IAdditiveIdentity<UBinarySize, UBinarySize>, IBitwiseOperators<UBinarySize, UBinarySize, UBinarySize>, 
	IComparisonOperators<UBinarySize, UBinarySize, bool>, IEqualityOperators<UBinarySize, UBinarySize, bool>, 
	IDecrementOperators<UBinarySize>, IDivisionOperators<UBinarySize, UBinarySize, UBinarySize>, 
	IIncrementOperators<UBinarySize>, IModulusOperators<UBinarySize, UBinarySize, UBinarySize>, 
	IMultiplicativeIdentity<UBinarySize, UBinarySize>, IMultiplyOperators<UBinarySize, UBinarySize, UBinarySize>, 
	INumber<UBinarySize>, INumberBase<UBinarySize>, ISubtractionOperators<UBinarySize, UBinarySize, UBinarySize>, 
	IUnaryNegationOperators<UBinarySize, UBinarySize>, IUnaryPlusOperators<UBinarySize, UBinarySize>, 
	IUtf8SpanFormattable, IUtf8SpanParsable<UBinarySize>, IMinMaxValue<UBinarySize>
Inheritance
Object    ValueType    UBinarySize
Implements
IComparable, IComparableUBinarySize, IEquatableUBinarySize, IFormattable, IParsableUBinarySize, ISpanFormattable, ISpanParsableUBinarySize, IUtf8SpanFormattable, IUtf8SpanParsableUBinarySize, IAdditionOperatorsUBinarySize, UBinarySize, UBinarySize, IAdditiveIdentityUBinarySize, UBinarySize, IBinaryNumberUBinarySize, IBitwiseOperatorsUBinarySize, UBinarySize, UBinarySize, IComparisonOperatorsUBinarySize, UBinarySize, Boolean, IDecrementOperatorsUBinarySize, IDivisionOperatorsUBinarySize, UBinarySize, UBinarySize, IEqualityOperatorsUBinarySize, UBinarySize, Boolean, IIncrementOperatorsUBinarySize, IMinMaxValueUBinarySize, IModulusOperatorsUBinarySize, UBinarySize, UBinarySize, IMultiplicativeIdentityUBinarySize, UBinarySize, IMultiplyOperatorsUBinarySize, UBinarySize, UBinarySize, INumberUBinarySize, INumberBaseUBinarySize, ISubtractionOperatorsUBinarySize, UBinarySize, UBinarySize, IUnaryNegationOperatorsUBinarySize, UBinarySize, IUnaryPlusOperatorsUBinarySize, UBinarySize, IXmlSerializable

Remarks

The underlying value is stored as a UInt64, as a whole number of bytes. Scaling is only used when formatting, such as when using the ToString(String, IFormatProvider) method.

Instances of this structure can be created by parsing a string containing a unit with a binary prefix, such as "1.5 GiB".

By default, this structure uses the definition that "1 KB" == 1024 bytes, identical to "1 KiB", and "1 MB" == "1 MiB" == 1048576 bytes, and so on. This behavior can be changed using the BinarySizeOptions enumeration, and by using certain formatting strings used with the ToString(String, IFormatProvider) method. The UIecBinarySize structure provides a wrapper that defaults to the behavior of the BinarySizeOptionsUseIecStandard flag.

Constructors

UBinarySize Initializes a new instance of the UBinarySize structure with the specified value.

Properties

AsExbi Gets the value of this instance in exbibytes.
AsGibi Gets the value of this instance in gibibytes.
AsKibi Gets the value of this instance in kibibytes.
AsMebi Gets the value of this instance in mebibytes.
AsPebi Gets the value of this instance in pebibytes.
AsTebi Gets the value of this instance in tebibytes.
Value Gets the number of bytes represented by this instance.

Methods

Add Returns the sum of two UBinarySize values.
CompareTo(Object)Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
CompareTo(UBinarySize) Compares this instance to a specified UBinarySize instance and returns an indication of their relative values.
Divide Divides one UBinarySize value by another.
Equals(Object)Indicates whether this instance and a specified object are equal.
(Overrides ValueTypeEquals(Object))
Equals(UBinarySize) Returns a value indicating whether this instance is equal to a specified UBinarySize value.
FromExbi Returns a UBinarySize that represents the specified number of exbibytes.
FromGibi Returns a UBinarySize that represents the specified number of gibibytes.
FromKibi Returns a UBinarySize that represents the specified number of kibibytes.
FromMebi Returns a UBinarySize that represents the specified number of mebibytes.
FromPebi Returns a UBinarySize that represents the specified number of pebibytes.
FromTebi Returns a UBinarySize that represents the specified number of tebibytes.
GetHashCodeReturns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Multiply Returns the product of two UBinarySize values.
Parse(ReadOnlySpanChar, IFormatProvider) Parses a span of characters into a UBinarySize structure.
Parse(String, IFormatProvider) Parses a string into a UBinarySize structure.
Parse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider) Parses a span of characters into a UBinarySize structure.
Parse(String, BinarySizeOptions, NumberStyles, IFormatProvider) Parses a string into a UBinarySize structure.
Remainder Returns the remainder of dividing one UBinarySize value by another.
Subtract Subtracts one UBinarySize value from another.
ToString Returns a string representation of the current value, using default formatting.
(Overrides ValueTypeToString)
ToString(String, IFormatProvider) Formats the value of the current UBinarySize instance using the specified format.
TryFormatTries to format the value of the current instance into the provided span of characters.
TryParse(ReadOnlySpanChar, UBinarySize) Tries to parse a span of characters into a UBinarySize structure.
TryParse(String, UBinarySize) Tries to parse a string into a UBinarySize structure.
TryParse(ReadOnlySpanChar, IFormatProvider, UBinarySize) Tries to parse a span of characters into a UBinarySize structure.
TryParse(String, IFormatProvider, UBinarySize) Tries to parse a string into a UBinarySize structure.
TryParse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider, UBinarySize) Tries to parse a span of characters into a UBinarySize structure.
TryParse(String, BinarySizeOptions, NumberStyles, IFormatProvider, UBinarySize) Tries to parse a string into a UBinarySize structure.

Operators

Addition(UBinarySize, UBinarySize) Adds two UBinarySize values.
Addition(UBinarySize, UInt64) Adds a UBinarySize value to a UInt64.
Addition(UInt64, UBinarySize) Adds a UInt64 value to a UBinarySize.
BitwiseAnd(UBinarySize, UBinarySize) Computes the bitwise-and of two UBinarySize values.
BitwiseAnd(UBinarySize, UInt64) Computes the bitwise-and of a UBinarySize value and a UInt64.
BitwiseAnd(UInt64, UBinarySize) Computes the bitwise-and of a UInt64 value and a UBinarySize.
BitwiseOr(UBinarySize, UBinarySize) Computes the bitwise-or of two UBinarySize values.
BitwiseOr(UBinarySize, UInt64) Computes the bitwise-or of a UBinarySize value and a UInt64.
BitwiseOr(UInt64, UBinarySize) Computes the bitwise-or of a UInt64 value and a UBinarySize.
CheckedAddition(UBinarySize, UBinarySize) Adds two UBinarySize values in a checked context.
CheckedAddition(UBinarySize, UInt64) Adds a UBinarySize value to a UInt64 in a checked context.
CheckedAddition(UInt64, UBinarySize) Adds a UInt64 value to a UBinarySize in a checked context.
CheckedDecrement(UBinarySize) Decrements a UBinarySize in a checked context.
CheckedIncrement(UBinarySize) Increments a UBinarySize in a checked context.
CheckedMultiply(UBinarySize, UBinarySize) Multiplies two UBinarySize values in a checked context.
CheckedMultiply(UBinarySize, UInt64) Multiplies a UBinarySize value by a UInt64 in a checked context.
CheckedMultiply(UInt64, UBinarySize) Multiplies a UInt64 value by a UBinarySize in a checked context.
CheckedSubtraction(UBinarySize, UBinarySize) Subtracts two UBinarySize values in a checked context.
CheckedSubtraction(UBinarySize, UInt64) Subtracts a UInt64 value from a UBinarySize in a checked context.
CheckedSubtraction(UInt64, UBinarySize) Subtracts a UBinarySize value from a UInt64 in a checked context.
Decrement(UBinarySize) Decrements a UBinarySize.
Division(UBinarySize, UBinarySize) Divides two UBinarySize values.
Division(UBinarySize, UInt64) Divides a UBinarySize value by a UInt64.
Division(UInt64, UBinarySize) Divides a UInt64 value by a UBinarySize.
Equality(UBinarySize, UBinarySize) Determines whether two specified UBinarySize values are the same.
Equality(UBinarySize, UInt64) Determines whether a UBinarySize value is the same as a UInt64 value.
Equality(UInt64, UBinarySize) Determines whether a UInt64 value is the same as a UBinarySize value.
ExclusiveOr(UBinarySize, UBinarySize) Computes the exclusive-or of two UBinarySize values.
ExclusiveOr(UBinarySize, UInt64) Computes the exclusive-or of a UBinarySize value and a UInt64.
ExclusiveOr(UInt64, UBinarySize) Computes the exclusive-or of a UInt64 value and a UBinarySize.
(UBinarySize to UInt64) Performs an explicit conversion from UBinarySize to UInt64.
(UInt64 to UBinarySize) Performs an implicit conversion from UInt64 to UBinarySize.
GreaterThan(UBinarySize, UBinarySize) Returns a value indicating whether a specified UBinarySize is greater than another UBinarySize.
GreaterThan(UBinarySize, UInt64) Returns a value indicating whether a specified UBinarySize is greater than a UInt64.
GreaterThan(UInt64, UBinarySize) Returns a value indicating whether a specified UInt64 is greater than a UBinarySize.
GreaterThanOrEqual(UBinarySize, UBinarySize) Returns a value indicating whether a specified UBinarySize is greater than or equal to another UBinarySize.
GreaterThanOrEqual(UBinarySize, UInt64) Returns a value indicating whether a specified UBinarySize is greater than or equal to a UInt64.
GreaterThanOrEqual(UInt64, UBinarySize) Returns a value indicating whether a specified UInt64 is greater than or equal to a UBinarySize.
Increment(UBinarySize) Increments a UBinarySize.
Inequality(UBinarySize, UBinarySize) Determines whether two specified UBinarySize values are different.
Inequality(UBinarySize, UInt64) Determines whether a UBinarySize value is different from a UInt64 value.
Inequality(UInt64, UBinarySize) Determines whether a UInt64 value is different from a UBinarySize value.
LeftShift(UBinarySize, Int32) Shifts the bits of a UBinarySize to the left.
LessThan(UBinarySize, UBinarySize) Returns a value indicating whether a specified UBinarySize is less than another UBinarySize.
LessThan(UBinarySize, UInt64) Returns a value indicating whether a specified UBinarySize is less than a UInt64.
LessThan(UInt64, UBinarySize) Returns a value indicating whether a specified UInt64 is less than a UBinarySize.
LessThanOrEqual(UBinarySize, UBinarySize) Returns a value indicating whether a specified UBinarySize is less than or equal to another UBinarySize.
LessThanOrEqual(UBinarySize, UInt64) Returns a value indicating whether a specified UBinarySize is less than or equal to a UInt64.
LessThanOrEqual(UInt64, UBinarySize) Returns a value indicating whether a specified UInt64 is less than or equal to a UBinarySize.
Modulus(UBinarySize, UBinarySize) Returns the remainder after dividing two UBinarySize values.
Modulus(UBinarySize, UInt64) Returns the remainder after dividing a UBinarySize value by a UInt64.
Modulus(UInt64, UBinarySize) Returns the remainder after dividing a UInt64 value by a UBinarySize.
Multiply(UBinarySize, UBinarySize) Multiplies two UBinarySize values.
Multiply(UBinarySize, UInt64) Multiplies a UBinarySize value by a UInt64.
Multiply(UInt64, UBinarySize) Multiplies a UInt64 value by a UBinarySize.
OnesComplement(UBinarySize) Computes the ones-complement representation of a UBinarySize.
RightShift(UBinarySize, Int32) Shifts the bits of a UBinarySize to the right.
Subtraction(UBinarySize, UBinarySize) Subtracts two UBinarySize values.
Subtraction(UBinarySize, UInt64) Subtracts a UInt64 value from a UBinarySize.
Subtraction(UInt64, UBinarySize) Subtracts a UBinarySize value from a UInt64.
UnaryPlus(UBinarySize) Returns the specified instance of UBinarySize.
UnsignedRightShift(UBinarySize, Int32) Shifts the bits of a UBinarySize to the right in an unsigned manner.

Fields

Exbi The size of an exbibyte (binary exabyte); 1,152,921,504,606,846,976 bytes.
Gibi The size of a gibibyte (binary gigabyte); 1,073,741,824 bytes.
Kibi The size of a kibibyte (binary kilobyte); 1,024 bytes.
MaxValue Represents the maximum UBinarySize value.
Mebi The size of a mebibyte (binary megabyte); 1,048,576 bytes.
MinValue Represents the minimum UBinarySize value.
Pebi The size of a pebibyte (binary petabyte); 1,125,899,906,842,624 bytes.
Tebi The size of a tebibyte (binary terabyte); 1,099,511,627,776 bytes.
Zero Gets a UBinarySize instance with a value of zero bytes.

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also