Prose.ByteSize

References
Provides utility methods for converting and formatting bits and bytes. Code copied from: https://github.com/omar/ByteSize

Constructors

ByteSize

#
Create a new bytesize.
public ByteSize(
byteSize
Number of bytes.
)

Fields

BitsInByte

#
The number of bits in a byte.
public const long BitsInByte = 8

BitSymbol

#
Bit unit symbol.
public const string BitSymbol = "b"

BytesInGigaByte

#
The number of bytes in a gigabyte.
public const long BytesInGigaByte = 1073741824

BytesInKiloByte

#
The number of bytes in a kilobyte.
public const long BytesInKiloByte = 1024

BytesInMegaByte

#
The number of bytes in a megabyte.
public const long BytesInMegaByte = 1048576

BytesInPetaByte

#
The number of bytes in a petabyte.
public const long BytesInPetaByte = 1125899906842624

BytesInTeraByte

#
The number of bytes in a terabyte.
public const long BytesInTeraByte = 1099511627776

ByteSymbol

#
Byte unit symbol.
public const string ByteSymbol = "B"

GigaByteSymbol

#
Gigabyte unit symbol.
public const string GigaByteSymbol = "GB"

KiloByteSymbol

#
Kilobyte unit symbol.
public const string KiloByteSymbol = "KB"

MaxValue

#
Largest representable size.
public static readonly Prose.ByteSize MaxValue

MegaByteSymbol

#
Megabyte unit symbol.
public const string MegaByteSymbol = "MB"

MinValue

#
Smallest representable size.
public static readonly Prose.ByteSize MinValue

PetaByteSymbol

#
Petabyte unit symbol.
public const string PetaByteSymbol = "PB"

TeraByteSymbol

#
Terabyte unit symbol.
public const string TeraByteSymbol = "TB"

Properties

Bits

#
Gets the total number of bits in this size.
public long Bits { get; }

Bytes

#
Gets the total number of bytes in this size.
public double Bytes { get; }

GigaBytes

#
Gets the total number of gigabytes in this size.
public double GigaBytes { get; }

KiloBytes

#
Gets the total number of kilobytes in this size.
public double KiloBytes { get; }

LargestWholeNumberSymbol

#
Gets the unit symbol which represents the largest non-zero amount.
public string LargestWholeNumberSymbol { get; }

LargestWholeNumberValue

#
Gets the amount of the largest non-zero unit.
public double LargestWholeNumberValue { get; }

MegaBytes

#
Gets the total number of megabytes in this size.
public double MegaBytes { get; }

PetaBytes

#
Gets the total number of petabytes in this size.
public double PetaBytes { get; }

TeraBytes

#
Gets the total number of terabytes in this size.
public double TeraBytes { get; }

Methods

Add

#
Add to this size.
public Prose.ByteSize Add()

AddBits

#
Add to this size.
public Prose.ByteSize AddBits(
value
)

AddBytes

#
Add to this size.
public Prose.ByteSize AddBytes(
value
)

AddGigaBytes

#
Add to this size.
public Prose.ByteSize AddGigaBytes(
value
)

AddKiloBytes

#
Add to this size.
public Prose.ByteSize AddKiloBytes(
value
)

AddMegaBytes

#
Add to this size.
public Prose.ByteSize AddMegaBytes(
value
)

AddPetaBytes

#
Add to this size.
public Prose.ByteSize AddPetaBytes(
value
)

AddTeraBytes

#
Add to this size.
public Prose.ByteSize AddTeraBytes(
value
)

CompareTo

#
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.
public int CompareTo(
other
An object to compare with this instance.
)

Equals

#
Test for equality.
public bool Equals(
value
)

Equals

#
Test for equality.
public override bool Equals(
value
)
ValueType.Equals

FromBits

#
Create a ByteSize instance from a number of bits.
public static Prose.ByteSize FromBits(
value
)

FromBytes

#
Create a ByteSize instance from a number of bytes.
public static Prose.ByteSize FromBytes(
value
)

FromGigaBytes

#
Create a ByteSize instance from a number of megabytes.
public static Prose.ByteSize FromGigaBytes(
value
)

FromKiloBytes

#
Create a ByteSize instance from a number of kilobytes.
public static Prose.ByteSize FromKiloBytes(
value
)

FromMegaBytes

#
Create a ByteSize instance from a number of megabytes.
public static Prose.ByteSize FromMegaBytes(
value
)

FromPetaBytes

#
Create a ByteSize instance from a number of petabytes.
public static Prose.ByteSize FromPetaBytes(
value
)

FromTeraBytes

#
Create a ByteSize instance from a number of terabytes.
public static Prose.ByteSize FromTeraBytes(
value
)

GetHashCode

#
Returns the hash code for this instance.
public override int GetHashCode()
A 32-bit signed integer that is the hash code for this instance.

Parse

#
Parse a string representing a size.
public static Prose.ByteSize Parse()

Subtract

#
Add to this size.
public Prose.ByteSize Subtract()

ToString

#
Converts the value of the current ByteSize object to a string. The metric prefix symbol (bit, byte, kilo, mega, giga, tera) used is the largest metric prefix such that the corresponding value is greater than or equal to one.
public override string ToString()

ToString

#
Format this instance using a formatting pattern.
public string ToString(
format
)

TryParse

#
Try to parse a string representing a size.
public static bool TryParse(
s,
String to parse.
result
Result.
)
True on success.

Operators

OperationResultDescription
Prose.ByteSize+Prose.ByteSizeProse.ByteSizeAdd two sizes.
Prose.ByteSize==Prose.ByteSizeboolTest two sizes for equality.
Prose.ByteSize>Prose.ByteSizeboolTest two sizes for larger than ness.
Prose.ByteSize>=Prose.ByteSizeboolTest two sizes for larger than ness.
Prose.ByteSize!=Prose.ByteSizeboolTest two sizes for inequality.
Prose.ByteSize<Prose.ByteSizeboolTest two sizes for smaller than ness.
Prose.ByteSize<=Prose.ByteSizeboolTest two sizes for smaller than ness.
Prose.ByteSize-Prose.ByteSizeProse.ByteSizeSubtract two sizes.
-Prose.ByteSizeProse.ByteSizeNegate a size.