<PackageReference Include="ByteSize" Version="2.1.2" />

ByteSizeLib.ByteSize

Represents a byte size value with support for decimal (KiloByte) and binary values (KibiByte).
public const long BitsInByte = 8

Number of bits in 1 byte.

public const string BitSymbol = "b"

Bit symbol.

public const long BytesInGibiByte = 1073741824

Number of bytes in 1 gibibyte.

public const long BytesInGigaByte = 1000000000

Number of bytes in 1 gigabyte.

public const long BytesInKibiByte = 1024

Number of bytes in 1 kibibyte.

public const long BytesInKiloByte = 1000

Number of bytes in 1 kilobyte.

public const long BytesInMebiByte = 1048576

Number of bytes in 1 mebibyte.

public const long BytesInMegaByte = 1000000

Number of bytes in 1 megabyte.

public const long BytesInPebiByte = 1125899906842624

Number of bytes in 1 pebibyte.

public const long BytesInPetaByte = 1000000000000000

Number of bytes in 1 petabyte.

public const long BytesInTebiByte = 1099511627776

Number of bytes in 1 tebibyte.

public const long BytesInTeraByte = 1000000000000

Number of bytes in 1 terabyte.

public const string ByteSymbol = "B"

Byte symbol.

public const string GibiByteSymbol = "GiB"

Gibibyte symbol.

public const string GigaByteSymbol = "GB"

Gigabyte symbol.

public const string KibiByteSymbol = "KiB"

Kibibyte symbol.

public const string KiloByteSymbol = "KB"

Kilobyte symbol.

public static readonly ByteSize MaxValue

Maximum number of allowed bits in an instance.

public const string MebiByteSymbol = "MiB"

Mebibyte symbol.

public const string MegaByteSymbol = "MB"

Megabyte symbol.

public static readonly ByteSize MinValue

Minimum number of allowed bits in an instance.

public const string PebiByteSymbol = "PiB"

Pebibyte symbol.

public const string PetaByteSymbol = "PB"

Petabyte symbol.

public const string TebiByteSymbol = "TiB"

Tebibyte symbol.

public const string TeraByteSymbol = "TB"

Terabyte symbol.

public long Bits { get; }

Gets the number of bits represented by this object.

public double Bytes { get; }

Gets the number of bytes represented by this object.

public double GibiBytes { get; }

Gets the number of gibibytes represented by this object.

public double GigaBytes { get; }

Gets the number of gigabytes represented by this object.

public double KibiBytes { get; }

Gets the number of kibibytes represented by this object.

public double KiloBytes { get; }

Gets the number of kilobytes represented by this object.

public string LargestWholeNumberBinarySymbol { get; }

Gets the largest whole number binary symbol. Example:

- 1024 KiB will return MiB

- 1023 KiB will return KiB

public double LargestWholeNumberBinaryValue { get; }

Gets the largest whole number binary value. Example:

- 1024 KiB will return 1

- 1023 KiB will return 1023

public string LargestWholeNumberDecimalSymbol { get; }

Gets the largest whole number decimal symbol. Example:

- 1000 KB will return MB

- 999 KB will return KB

public double LargestWholeNumberDecimalValue { get; }

Gets the largest whole number decimal value. Example:

- 1000 KB will return 1

- 999 KB will return 999

public double MebiBytes { get; }

Gets the number of mebibytes represented by this object.

public double MegaBytes { get; }

Gets the number of megabytes represented by this object.

public double PebiBytes { get; }

Gets the number of pebibytes represented by this object.

public double PetaBytes { get; }

Gets the number of petabytes represented by this object.

public double TebiBytes { get; }

Gets the number of tebibytes represented by this object.

public double TeraBytes { get; }

Gets the number of terabytes represented by this object.

public ByteSize(long bits)

Initializes a new instance of the ByteSize structure to the specified number of units.

public ByteSize(double bytes)

Initializes a new instance of the ByteSize structure to the specified number of units.

public static ByteSize FromBits(long value)

public static ByteSize FromBytes(double value)

public static ByteSize FromGibiBytes(double value)

public static ByteSize FromGigaBytes(double value)

public static ByteSize FromKibiBytes(double value)

public static ByteSize FromKiloBytes(double value)

public static ByteSize FromMebiBytes(double value)

public static ByteSize FromMegaBytes(double value)

public static ByteSize FromPebiBytes(double value)

public static ByteSize FromPetaBytes(double value)

public static ByteSize FromTebiBytes(double value)

public static ByteSize FromTeraBytes(double value)

public static ByteSize op_Addition(ByteSize b1, ByteSize b2)

public static ByteSize op_Decrement(ByteSize b)

Returns a new instance whose value is 1 byte less than this instance.

public static ByteSize op_Division(ByteSize a, ByteSize b)

Divides two instances.

public static bool op_Equality(ByteSize b1, ByteSize b2)

Indicates whether two instances have equal number of bits.

public static bool op_GreaterThan(ByteSize b1, ByteSize b2)

Indicates whether one instance has more bits than the other.

public static bool op_GreaterThanOrEqual(ByteSize b1, ByteSize b2)

Indicates whether one instance has more bits or equal than the other.

public static ByteSize op_Increment(ByteSize b)

Returns an instance whose value is 1 byte greater than this instance.

public static bool op_Inequality(ByteSize b1, ByteSize b2)

Indicates whether two instances have different number of bits.

public static bool op_LessThan(ByteSize b1, ByteSize b2)

Indicates whether one instance has less bits than the other.

public static bool op_LessThanOrEqual(ByteSize b1, ByteSize b2)

Indicates whether one instance has less or equal bits than the other.

public static ByteSize op_Multiply(ByteSize a, ByteSize b)

Multiply two instances.

public static ByteSize op_Subtraction(ByteSize b1, ByteSize b2)

Returns a new instance whose value is the negative value of the specified instance.

public static ByteSize Parse(string s)

Converts the string representation of a binary or decimal byte to its ByteSize equivalent.

public static ByteSize Parse(string s, IFormatProvider formatProvider)

Converts the string representation of a binary or decimal byte to its ByteSize equivalent.

public static ByteSize Parse(string s, NumberStyles numberStyles, IFormatProvider formatProvider)

Converts the string representation of a binary or decimal byte to its ByteSize equivalent.

public static bool TryParse(string s, out ByteSize result)

Converts the string representation of a binary or decimal byte to its ByteSize equivalent. Return value indicates success or failure of the parsing.

public static bool TryParse(string s, NumberStyles numberStyles, IFormatProvider formatProvider, out ByteSize result)

Converts the string representation of a binary or decimal byte to its ByteSize equivalent. Return value indicates success or failure of the parsing.

public ByteSize Add(ByteSize bs)

Returns a new ByteSize object whose value is the sum of the specified value and this instance.

public ByteSize AddBits(long value)

public ByteSize AddBytes(double value)

public ByteSize AddGibiBytes(double value)

public ByteSize AddGigaBytes(double value)

public ByteSize AddKibiBytes(double value)

public ByteSize AddKiloBytes(double value)

public ByteSize AddMebiBytes(double value)

public ByteSize AddMegaBytes(double value)

public ByteSize AddPebiBytes(double value)

public ByteSize AddPetaBytes(double value)

public ByteSize AddTebiBytes(double value)

public ByteSize AddTeraBytes(double value)

public int CompareTo(ByteSize other)

Compares this instance's bit count to the other instance's bit count.

public bool Equals(ByteSize value)

Indicates whether an instance has equal number of bits to this instance.

Returns a new ByteSize object whose value is the difference of the specified value and this instance.

public string ToBinaryString()

Converts the value of the current object to a binary byte string. The prefix symbol (bit, byte, kibi, mebi, etc.) used is the largest prefix such that the corresponding value is greater than or equal to one.

public string ToBinaryString(IFormatProvider formatProvider)

Converts the value of the current object to a binary byte string. The prefix symbol (bit, byte, kibi, mebi, etc.) used is the largest prefix such that the corresponding value is greater than or equal to one. Use ToString for decimal string representation.

public string ToString(string format)

Converts the value of the current object to a decimal byte string. The prefix symbol (bit, byte, kilo, mega, etc.) used is the largest prefix such that the corresponding value is greater than or equal to one. Use ToBinaryString for binary string representation.

public string ToString(string format, IFormatProvider provider)

Converts the value of the current object to a decimal byte string. The prefix symbol (bit, byte, kilo, mega, etc.) used is the largest prefix such that the corresponding value is greater than or equal to one. Use ToBinaryString for binary string representation.

public string ToString(string format, IFormatProvider provider, bool useBinaryByte)

Converts the value of the current object to a decimal byte string. The prefix symbol (bit, byte, kilo, mega, etc.) used is the largest prefix such that the corresponding value is greater than or equal to one. Use ToBinaryString for binary string representation.