public struct ByteSize : System.IComparable<Humanizer.ByteSize>, System.IEquatable<Humanizer.ByteSize>, System.IComparable, System.IFormattableImplements System.IComparable<ByteSize>, System.IEquatable<ByteSize>, System.IComparable, System.IFormattable
public ByteSize(double byteSize);byteSize System.Double
public const string Bit = "bit";public const long BitsInByte = 8;public const string BitSymbol = "b";public const string Byte = "byte";Gets the number of bytes in one decimal SI exabyte.
public const long BytesInDecimalExabyte = 1000000000000000000;Gets the number of bytes in one decimal SI gigabyte.
public const long BytesInDecimalGigabyte = 1000000000;Gets the number of bytes in one decimal SI kilobyte.
public const long BytesInDecimalKilobyte = 1000;Gets the number of bytes in one decimal SI megabyte.
public const long BytesInDecimalMegabyte = 1000000;Gets the number of bytes in one decimal SI petabyte.
public const long BytesInDecimalPetabyte = 1000000000000000;Gets the number of bytes in one decimal SI terabyte.
public const long BytesInDecimalTerabyte = 1000000000000;public const long BytesInExabyte = 1000000000000000000;The number of bytes in a gibibyte, equivalent to the established gigabyte factor.
public const long BytesInGibibyte = 1073741824;public const long BytesInGigabyte = 1073741824;The number of bytes in a kibibyte, equivalent to the established kilobyte factor.
public const long BytesInKibibyte = 1024;public const long BytesInKilobyte = 1024;The number of bytes in a mebibyte, equivalent to the established megabyte factor.
public const long BytesInMebibyte = 1048576;public const long BytesInMegabyte = 1048576;public const long BytesInPebibyte = 1125899906842624;public const long BytesInPetabyte = 1000000000000000;The number of bytes in a tebibyte, equivalent to the established terabyte factor.
public const long BytesInTebibyte = 1099511627776;public const long BytesInTerabyte = 1099511627776;public const string ByteSymbol = "B";public const string Exabyte = "exabyte";public const string ExabyteSymbol = "EB";The name of a gibibyte.
public const string Gibibyte = "gibibyte";The symbol for a gibibyte.
public const string GibibyteSymbol = "GiB";public const string Gigabyte = "gigabyte";public const string GigabyteSymbol = "GB";The name of a kibibyte.
public const string Kibibyte = "kibibyte";The symbol for a kibibyte.
public const string KibibyteSymbol = "KiB";public const string Kilobyte = "kilobyte";public const string KilobyteSymbol = "KB";public static readonly ByteSize MaxValue;The name of a mebibyte.
public const string Mebibyte = "mebibyte";The symbol for a mebibyte.
public const string MebibyteSymbol = "MiB";public const string Megabyte = "megabyte";public const string MegabyteSymbol = "MB";public static readonly ByteSize MinValue;public const string Pebibyte = "pebibyte";public const string PebibyteSymbol = "PiB";public const string Petabyte = "petabyte";public const string PetabyteSymbol = "PB";The name of a tebibyte.
public const string Tebibyte = "tebibyte";The symbol for a tebibyte.
public const string TebibyteSymbol = "TiB";public const string Terabyte = "terabyte";public const string TerabyteSymbol = "TB";public readonly long Bits { get; }public readonly double Bytes { get; }Gets this value expressed in decimal SI exabytes.
public readonly double DecimalExabytes { get; }Gets this value expressed in decimal SI gigabytes.
public readonly double DecimalGigabytes { get; }Gets this value expressed in decimal SI kilobytes.
public readonly double DecimalKilobytes { get; }Gets this value expressed in decimal SI megabytes.
public readonly double DecimalMegabytes { get; }Gets this value expressed in decimal SI petabytes.
public readonly double DecimalPetabytes { get; }Gets this value expressed in decimal SI terabytes.
public readonly double DecimalTerabytes { get; }public readonly double Exabytes { get; }Gets the size in gibibytes.
public readonly double Gibibytes { get; }public readonly double Gigabytes { get; }Gets the size in kibibytes.
public readonly double Kibibytes { get; }public readonly double Kilobytes { get; }public readonly string LargestWholeNumberFullWord { get; }public readonly string LargestWholeNumberSymbol { get; }public readonly double LargestWholeNumberValue { get; }Gets the size in mebibytes.
public readonly double Mebibytes { get; }public readonly double Megabytes { get; }public readonly double Pebibytes { get; }public readonly double Petabytes { get; }Gets the size in tebibytes.
public readonly double Tebibytes { get; }public readonly double Terabytes { get; }public readonly Humanizer.ByteSize Add(Humanizer.ByteSize bs);bs ByteSize
public readonly Humanizer.ByteSize AddBits(long value);value System.Int64
public readonly Humanizer.ByteSize AddBytes(double value);value System.Double
public readonly Humanizer.ByteSize AddExabytes(double value);value System.Double
public readonly Humanizer.ByteSize AddGigabytes(double value);value System.Double
public readonly Humanizer.ByteSize AddKilobytes(double value);value System.Double
public readonly Humanizer.ByteSize AddMegabytes(double value);value System.Double
public readonly Humanizer.ByteSize AddPebibytes(double value);value System.Double
public readonly Humanizer.ByteSize AddPetabytes(double value);value System.Double
public readonly Humanizer.ByteSize AddTerabytes(double value);value System.Double
public readonly int CompareTo(Humanizer.ByteSize other);other ByteSize
public readonly int CompareTo(object? obj);obj System.Object
Implements CompareTo(object)
public readonly bool Equals(Humanizer.ByteSize value);value ByteSize
public override readonly bool Equals(object? value);value System.Object
Formats this value with an explicitly selected unit system.
public readonly string Format(Humanizer.ByteSizeUnitSystem unitSystem, string? format=null, System.IFormatProvider? formatProvider=null);unitSystem ByteSizeUnitSystem
The unit system to use.
format System.String
The numeric format and optional unit token. For DecimalSi and
BinaryIec, SI/IEC-prefixed unit tokens are matched case-insensitively,
while b and B remain case-sensitive; output uses canonical symbol casing.
Legacy preserves established matching behavior. At most one distinct
unescaped, unquoted unit token is permitted, although the same token may be repeated across numeric format
sections.
formatProvider System.IFormatProvider
The provider used to format the numeric value.
System.String
The formatted byte size.
System.ArgumentOutOfRangeException
unitSystem is not defined.
System.FormatException
format is invalid, contains mixed unit tokens, or selects a token not supported by the
selected non-legacy system.
Formats this value with localized unit words from an explicitly selected unit system.
public readonly string FormatFullWords(Humanizer.ByteSizeUnitSystem unitSystem, string? format=null, System.IFormatProvider? formatProvider=null);unitSystem ByteSizeUnitSystem
The unit system to use.
format System.String
The numeric format and optional unit token. For DecimalSi and
BinaryIec, SI/IEC-prefixed unit tokens are matched case-insensitively,
while b and B remain case-sensitive; localized words replace the selected token.
Legacy preserves established matching behavior. At most one distinct
unescaped, unquoted unit token is permitted, although the same token may be repeated across numeric format
sections.
formatProvider System.IFormatProvider
The provider used to format the numeric value and select localized unit words.
System.String
The formatted byte size using localized unit words.
System.ArgumentOutOfRangeException
unitSystem is not defined.
System.FormatException
format is invalid, contains mixed unit tokens, or selects a token not supported by the
selected non-legacy system.
public static Humanizer.ByteSize FromBits(long value);value System.Int64
public static Humanizer.ByteSize FromBytes(double value);value System.Double
Creates a byte size from a number of decimal SI exabytes.
public static Humanizer.ByteSize FromDecimalExabytes(double value);value System.Double
The number of decimal SI exabytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
Creates a byte size from a number of decimal SI gigabytes.
public static Humanizer.ByteSize FromDecimalGigabytes(double value);value System.Double
The number of decimal SI gigabytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
Creates a byte size from a number of decimal SI kilobytes.
public static Humanizer.ByteSize FromDecimalKilobytes(double value);value System.Double
The number of decimal SI kilobytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
Creates a byte size from a number of decimal SI megabytes.
public static Humanizer.ByteSize FromDecimalMegabytes(double value);value System.Double
The number of decimal SI megabytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
Creates a byte size from a number of decimal SI petabytes.
public static Humanizer.ByteSize FromDecimalPetabytes(double value);value System.Double
The number of decimal SI petabytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
Creates a byte size from a number of decimal SI terabytes.
public static Humanizer.ByteSize FromDecimalTerabytes(double value);value System.Double
The number of decimal SI terabytes.
ByteSize
The equivalent byte size.
System.ArgumentOutOfRangeException
value is not finite or is outside the range supported by Bits.
public static Humanizer.ByteSize FromExabytes(double value);value System.Double
Creates a byte size from a number of gibibytes.
public static Humanizer.ByteSize FromGibibytes(double value);value System.Double
public static Humanizer.ByteSize FromGigabytes(double value);value System.Double
Creates a byte size from a number of kibibytes.
public static Humanizer.ByteSize FromKibibytes(double value);value System.Double
public static Humanizer.ByteSize FromKilobytes(double value);value System.Double
Creates a byte size from a number of mebibytes.
public static Humanizer.ByteSize FromMebibytes(double value);value System.Double
public static Humanizer.ByteSize FromMegabytes(double value);value System.Double
public static Humanizer.ByteSize FromPebibytes(double value);value System.Double
public static Humanizer.ByteSize FromPetabytes(double value);value System.Double
Creates a byte size from a number of tebibytes.
public static Humanizer.ByteSize FromTebibytes(double value);value System.Double
public static Humanizer.ByteSize FromTerabytes(double value);value System.Double
public override readonly int GetHashCode();public readonly string GetLargestWholeNumberFullWord(System.IFormatProvider? provider=null);provider System.IFormatProvider
public readonly string GetLargestWholeNumberSymbol(System.IFormatProvider? provider=null);provider System.IFormatProvider
public static Humanizer.ByteSize Parse(string s);public static Humanizer.ByteSize Parse(string s, System.IFormatProvider? formatProvider);formatProvider System.IFormatProvider
Parses a byte size using only the tokens defined by the selected unit system.
public static Humanizer.ByteSize ParseWithUnitSystem(string s, Humanizer.ByteSizeUnitSystem unitSystem, System.IFormatProvider? formatProvider=null);The text to parse.
unitSystem ByteSizeUnitSystem
The unit system whose tokens are accepted.
formatProvider System.IFormatProvider
The provider used to parse the numeric value.
ByteSize
The parsed byte size.
System.ArgumentNullException
s is null.
System.ArgumentOutOfRangeException
unitSystem is not defined.
System.FormatException
s is not valid for the selected unit system.
For DecimalSi and BinaryIec, SI/IEC-prefixed
unit tokens are matched case-insensitively, while b and B remain case-sensitive.
Legacy parsing preserves the established behavior.
public readonly Humanizer.ByteSize Subtract(Humanizer.ByteSize bs);bs ByteSize
Converts the value of the current ByteSize object to a string with full words. The metric prefix symbol (bit, byte, kilo, mega, giga, tera, peta, exa) used is the largest metric prefix such that the corresponding value is greater than or equal to one.
public readonly string ToFullWords(string? format=null, System.IFormatProvider? provider=null);format System.String
provider System.IFormatProvider
Converts the value of the current ByteSize object to a string. The metric prefix symbol (bit, byte, kilo, mega, giga, tera, peta, exa) used is the largest metric prefix such that the corresponding value is greater than or equal to one.
public override readonly string ToString();public readonly string ToString(string? format);format System.String
public readonly string ToString(string? format, System.IFormatProvider? provider);format System.String
provider System.IFormatProvider
Implements ToString(string, IFormatProvider)
public readonly string ToString(System.IFormatProvider? provider);provider System.IFormatProvider
public static bool TryParse(string? s, out Humanizer.ByteSize result);result ByteSize
public static bool TryParse(string? s, System.IFormatProvider? formatProvider, out Humanizer.ByteSize result);formatProvider System.IFormatProvider
result ByteSize
public static bool TryParse(System.ReadOnlySpan<char> s, out Humanizer.ByteSize result);s System.ReadOnlySpan<System.Char>
result ByteSize
public static bool TryParse(System.ReadOnlySpan<char> s, System.IFormatProvider? formatProvider, out Humanizer.ByteSize result);s System.ReadOnlySpan<System.Char>
formatProvider System.IFormatProvider
result ByteSize
Attempts to parse a byte-size character span using only the tokens defined by the selected unit system.
public static bool TryParseSpanWithUnitSystem(System.ReadOnlySpan<char> s, Humanizer.ByteSizeUnitSystem unitSystem, out Humanizer.ByteSize result);s System.ReadOnlySpan<System.Char>
The character span to parse.
unitSystem ByteSizeUnitSystem
The unit system whose tokens are accepted.
result ByteSize
When this method returns, contains the parsed byte size if parsing succeeded; otherwise, the default value.
System.Boolean
true if parsing succeeded; otherwise, false.
System.ArgumentOutOfRangeException
unitSystem is not defined.
For DecimalSi and BinaryIec, SI/IEC-prefixed
unit tokens are matched case-insensitively, while b and B remain case-sensitive.
Legacy parsing preserves the established behavior.
ByteSize.TryParseSpanWithUnitSystem(ReadOnlySpan<char>, ByteSizeUnitSystem, IFormatProvider, ByteSize) Method
Attempts to parse a byte-size character span using only the tokens defined by the selected unit system.
public static bool TryParseSpanWithUnitSystem(System.ReadOnlySpan<char> s, Humanizer.ByteSizeUnitSystem unitSystem, System.IFormatProvider? formatProvider, out Humanizer.ByteSize result);s System.ReadOnlySpan<System.Char>
The character span to parse.
unitSystem ByteSizeUnitSystem
The unit system whose tokens are accepted.
formatProvider System.IFormatProvider
The provider used to parse the numeric value.
result ByteSize
When this method returns, contains the parsed byte size if parsing succeeded; otherwise, the default value.
System.Boolean
true if parsing succeeded; otherwise, false.
System.ArgumentOutOfRangeException
unitSystem is not defined.
For DecimalSi and BinaryIec, SI/IEC-prefixed
unit tokens are matched case-insensitively, while b and B remain case-sensitive.
Legacy parsing preserves the established behavior.
Attempts to parse a byte size using only the tokens defined by the selected unit system.
public static bool TryParseWithUnitSystem(string? s, Humanizer.ByteSizeUnitSystem unitSystem, out Humanizer.ByteSize result);The text to parse.
unitSystem ByteSizeUnitSystem
The unit system whose tokens are accepted.
result ByteSize
When this method returns, contains the parsed byte size if parsing succeeded; otherwise, the default value.
System.Boolean
true if parsing succeeded; otherwise, false.
System.ArgumentOutOfRangeException
unitSystem is not defined.
For DecimalSi and BinaryIec, SI/IEC-prefixed
unit tokens are matched case-insensitively, while b and B remain case-sensitive.
Legacy parsing preserves the established behavior.
Attempts to parse a byte size using only the tokens defined by the selected unit system.
public static bool TryParseWithUnitSystem(string? s, Humanizer.ByteSizeUnitSystem unitSystem, System.IFormatProvider? formatProvider, out Humanizer.ByteSize result);The text to parse.
unitSystem ByteSizeUnitSystem
The unit system whose tokens are accepted.
formatProvider System.IFormatProvider
The provider used to parse the numeric value.
result ByteSize
When this method returns, contains the parsed byte size if parsing succeeded; otherwise, the default value.
System.Boolean
true if parsing succeeded; otherwise, false.
System.ArgumentOutOfRangeException
unitSystem is not defined.
For DecimalSi and BinaryIec, SI/IEC-prefixed
unit tokens are matched case-insensitively, while b and B remain case-sensitive.
Legacy parsing preserves the established behavior.
public static Humanizer.ByteSize operator +(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static Humanizer.ByteSize operator --(Humanizer.ByteSize b);b ByteSize
public static bool operator ==(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static bool operator >(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static bool operator >=(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static Humanizer.ByteSize operator ++(Humanizer.ByteSize b);b ByteSize
public static bool operator !=(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static bool operator <(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static bool operator <=(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static Humanizer.ByteSize operator -(Humanizer.ByteSize b1, Humanizer.ByteSize b2);b1 ByteSize
b2 ByteSize
public static Humanizer.ByteSize operator -(Humanizer.ByteSize b);b ByteSize