BinarySize Structure

Represents a 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.1.0+e86ae44c345422a1011f7fa7b6b715bf3d1a34ce
C#
[SerializableAttribute]
[TypeConverterAttribute(typeof(BinarySizeConverter))]
public readonly struct BinarySize : IEquatable<BinarySize>, 
	IComparable<BinarySize>, IComparable, IFormattable, IXmlSerializable, 
	ISpanFormattable, ISpanParsable<BinarySize>, IParsable<BinarySize>, 
	IBinaryNumber<BinarySize>, IAdditionOperators<BinarySize, BinarySize, BinarySize>, 
	IAdditiveIdentity<BinarySize, BinarySize>, IBitwiseOperators<BinarySize, BinarySize, BinarySize>, 
	IComparisonOperators<BinarySize, BinarySize, bool>, IEqualityOperators<BinarySize, BinarySize, bool>, 
	IDecrementOperators<BinarySize>, IDivisionOperators<BinarySize, BinarySize, BinarySize>, 
	IIncrementOperators<BinarySize>, IModulusOperators<BinarySize, BinarySize, BinarySize>, 
	IMultiplicativeIdentity<BinarySize, BinarySize>, IMultiplyOperators<BinarySize, BinarySize, BinarySize>, 
	INumber<BinarySize>, INumberBase<BinarySize>, ISubtractionOperators<BinarySize, BinarySize, BinarySize>, 
	IUnaryNegationOperators<BinarySize, BinarySize>, IUnaryPlusOperators<BinarySize, BinarySize>, 
	ISignedNumber<BinarySize>, IMinMaxValue<BinarySize>
Inheritance
Object    ValueType    BinarySize
Implements
IComparable, IComparableBinarySize, IEquatableBinarySize, IFormattable, IParsableBinarySize, ISpanFormattable, ISpanParsableBinarySize, IAdditionOperatorsBinarySize, BinarySize, BinarySize, IAdditiveIdentityBinarySize, BinarySize, IBinaryNumberBinarySize, IBitwiseOperatorsBinarySize, BinarySize, BinarySize, IComparisonOperatorsBinarySize, BinarySize, Boolean, IDecrementOperatorsBinarySize, IDivisionOperatorsBinarySize, BinarySize, BinarySize, IEqualityOperatorsBinarySize, BinarySize, Boolean, IIncrementOperatorsBinarySize, IMinMaxValueBinarySize, IModulusOperatorsBinarySize, BinarySize, BinarySize, IMultiplicativeIdentityBinarySize, BinarySize, IMultiplyOperatorsBinarySize, BinarySize, BinarySize, INumberBinarySize, INumberBaseBinarySize, ISignedNumberBinarySize, ISubtractionOperatorsBinarySize, BinarySize, BinarySize, IUnaryNegationOperatorsBinarySize, BinarySize, IUnaryPlusOperatorsBinarySize, BinarySize, IXmlSerializable

Remarks

The underlying value is stored as a Int64, 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 see BinarySizeOptions enumeration, and formatting strings used with the ToString(String, IFormatProvider) method. The IecBinarySize structure provides a wrapper that defaults to the behavior of the BinarySizeOptionsUseIecStandard flag.

Constructors

BinarySize Initializes a new instance of the BinarySize 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 BinarySize values.
CompareTo(BinarySize) Compares this instance to a specified BinarySize instance and returns an indication of their relative 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.
Divide Divides one BinarySize value by another.
Equals(BinarySize) Returns a value indicating whether this instance is equal to a specified BinarySize value.
Equals(Object)Indicates whether this instance and a specified object are equal.
(Overrides ValueTypeEquals(Object))
FromExbi Returns a BinarySize that represents the specified number of exbibytes.
FromGibi Returns a BinarySize that represents the specified number of gibibytes.
FromKibi Returns a BinarySize that represents the specified number of kibibytes.
FromMebi Returns a BinarySize that represents the specified number of mebibytes.
FromPebi Returns a BinarySize that represents the specified number of pebibytes.
FromTebi Returns a BinarySize 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 BinarySize values.
Negate Returns the negation of a BinarySize value.
Parse(ReadOnlySpanChar, IFormatProvider) Parses a span of characters into a BinarySize structure.
Parse(String, IFormatProvider) Parses a string into a BinarySize structure.
Parse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider) Parses a span of characters into a BinarySize structure.
Parse(String, BinarySizeOptions, NumberStyles, IFormatProvider) Parses a string into a BinarySize structure.
Remainder Returns the remainder of dividing one BinarySize value by another.
Subtract Subtracts one BinarySize 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 BinarySize instance using the specified format.
TryFormatTries to format the value of the current instance into the provided span of characters.
TryParse(ReadOnlySpanChar, BinarySize) Tries to parse a span of characters into a BinarySize structure.
TryParse(String, BinarySize) Tries to parse a string into a BinarySize structure.
TryParse(ReadOnlySpanChar, IFormatProvider, BinarySize) Tries to parse a span of characters into a BinarySize structure.
TryParse(String, IFormatProvider, BinarySize) Tries to parse a string into a BinarySize structure.
TryParse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider, BinarySize) Tries to parse a span of characters into a BinarySize structure.
TryParse(String, BinarySizeOptions, NumberStyles, IFormatProvider, BinarySize) Tries to parse a string into a BinarySize structure.

Operators

Addition(BinarySize, BinarySize) Adds two BinarySize values.
Addition(BinarySize, Int64) Adds a BinarySize value to a Int64.
Addition(Int64, BinarySize) Adds a Int64 value to a BinarySize.
BitwiseAnd(BinarySize, BinarySize) Computes the bitwise-and of two BinarySize values.
BitwiseAnd(BinarySize, Int64) Computes the bitwise-and of a BinarySize value and a Int64.
BitwiseAnd(Int64, BinarySize) Computes the bitwise-and of a Int64 value and a BinarySize.
BitwiseOr(BinarySize, BinarySize) Computes the bitwise-or of two BinarySize values.
BitwiseOr(BinarySize, Int64) Computes the bitwise-or of a BinarySize value and a Int64.
BitwiseOr(Int64, BinarySize) Computes the bitwise-or of a Int64 value and a BinarySize.
CheckedAddition(BinarySize, BinarySize) Adds two BinarySize values in a checked context.
CheckedAddition(BinarySize, Int64) Adds a BinarySize value to a Int64 in a checked context.
CheckedAddition(Int64, BinarySize) Adds a Int64 value to a BinarySize in a checked context.
CheckedDecrement(BinarySize) Decrements a BinarySize in a checked context.
CheckedIncrement(BinarySize) Increments a BinarySize in a checked context.
CheckedMultiply(BinarySize, BinarySize) Multiplies two BinarySize values in a checked context.
CheckedMultiply(BinarySize, Int64) Multiplies a BinarySize value by a Int64 in a checked context.
CheckedMultiply(Int64, BinarySize) Multiplies a Int64 value by a BinarySize in a checked context.
CheckedSubtraction(BinarySize, BinarySize) Subtracts two BinarySize values in a checked context.
CheckedSubtraction(BinarySize, Int64) Subtracts a Int64 value from a BinarySize in a checked context.
CheckedSubtraction(Int64, BinarySize) Subtracts a BinarySize value from a Int64 in a checked context.
Decrement(BinarySize) Decrements a BinarySize.
Division(BinarySize, BinarySize) Divides two BinarySize values.
Division(BinarySize, Int64) Divides a BinarySize value by a Int64.
Division(Int64, BinarySize) Divides a Int64 value by a BinarySize.
Equality(BinarySize, BinarySize) Determines whether two specified BinarySize values are the same.
Equality(BinarySize, Int64) Determines whether a BinarySize value is the same as a Int64 value.
Equality(Int64, BinarySize) Determines whether a Int64 value is the same as a BinarySize value.
ExclusiveOr(BinarySize, BinarySize) Computes the exclusive-or of two BinarySize values.
ExclusiveOr(BinarySize, Int64) Computes the exclusive-or of a BinarySize value and a Int64.
ExclusiveOr(Int64, BinarySize) Computes the exclusive-or of a Int64 value and a BinarySize.
(BinarySize to Int64) Performs an explicit conversion from BinarySize to Int64.
(Int64 to BinarySize) Performs an implicit conversion from Int64 to BinarySize.
GreaterThan(BinarySize, BinarySize) Returns a value indicating whether a specified BinarySize is greater than another BinarySize.
GreaterThan(BinarySize, Int64) Returns a value indicating whether a specified BinarySize is greater than a Int64.
GreaterThan(Int64, BinarySize) Returns a value indicating whether a specified Int64 is greater than a BinarySize.
GreaterThanOrEqual(BinarySize, BinarySize) Returns a value indicating whether a specified BinarySize is greater than or equal to another BinarySize.
GreaterThanOrEqual(BinarySize, Int64) Returns a value indicating whether a specified BinarySize is greater than or equal to a Int64.
GreaterThanOrEqual(Int64, BinarySize) Returns a value indicating whether a specified Int64 is greater than or equal to a BinarySize.
Increment(BinarySize) Increments a BinarySize.
Inequality(BinarySize, BinarySize) Determines whether two specified BinarySize values are different.
Inequality(BinarySize, Int64) Determines whether a BinarySize value is different from a Int64 value.
Inequality(Int64, BinarySize) Determines whether a Int64 value is different from a BinarySize value.
LeftShift(BinarySize, Int32) Shifts the bits of a BinarySize to the left.
LessThan(BinarySize, BinarySize) Returns a value indicating whether a specified BinarySize is less than another BinarySize.
LessThan(BinarySize, Int64) Returns a value indicating whether a specified BinarySize is less than a Int64.
LessThan(Int64, BinarySize) Returns a value indicating whether a specified Int64 is less than a BinarySize.
LessThanOrEqual(BinarySize, BinarySize) Returns a value indicating whether a specified BinarySize is less than or equal to another BinarySize.
LessThanOrEqual(BinarySize, Int64) Returns a value indicating whether a specified BinarySize is less than or equal to a Int64.
LessThanOrEqual(Int64, BinarySize) Returns a value indicating whether a specified Int64 is less than or equal to a BinarySize.
Modulus(BinarySize, BinarySize) Returns the remainder after dividing two BinarySize values.
Modulus(BinarySize, Int64) Returns the remainder after dividing a BinarySize value by a Int64.
Modulus(Int64, BinarySize) Returns the remainder after dividing a Int64 value by a BinarySize.
Multiply(BinarySize, BinarySize) Multiplies two BinarySize values.
Multiply(BinarySize, Int64) Multiplies a BinarySize value by a Int64.
Multiply(Int64, BinarySize) Multiplies a Int64 value by a BinarySize.
OnesComplement(BinarySize) Computes the ones-complement representation of a BinarySize.
RightShift(BinarySize, Int32) Shifts the bits of a BinarySize to the right.
Subtraction(BinarySize, BinarySize) Subtracts two BinarySize values.
Subtraction(BinarySize, Int64) Subtracts a Int64 value from a BinarySize.
Subtraction(Int64, BinarySize) Subtracts a BinarySize value from a Int64.
UnaryNegation(BinarySize) Negates a BinarySize value.
UnaryPlus(BinarySize) Returns the specified instance of BinarySize.
UnsignedRightShift(BinarySize, Int32) Shifts the bits of a BinarySize 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 BinarySize value.
Mebi The size of a mebibyte (binary megabyte); 1,048,576 bytes.
MinValue Represents the minimum BinarySize 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 BinarySize 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