Struct ByteSize
Represents a byte size value
public readonly struct ByteSize : IComparable<ByteSize>, IFormattable, IUtf8SpanFormattable, IComparisonOperators<ByteSize, ByteSize, bool>, IEqualityOperators<ByteSize, ByteSize, bool>, IAdditionOperators<ByteSize, ByteSize, ByteSize>, ISubtractionOperators<ByteSize, ByteSize, ByteSize>, IDivisionOperators<ByteSize, long, ByteSize>, IDivisionOperators<ByteSize, double, ByteSize>, IMultiplyOperators<ByteSize, long, ByteSize>, IIncrementOperators<ByteSize>, IDecrementOperators<ByteSize>, IEquatable<ByteSize>
- Implements
- Inherited Members
Constructors
ByteSize(long)
Represents a byte size value
public ByteSize(long ByteCount)
Parameters
ByteCount
long
Properties
ByteCount
public long ByteCount { get; init; }
Property Value
GibiBytes
Gets the number of GibiBytes represented by this object.
public double GibiBytes { get; }
Property Value
GigaBytes
Gets the number of GigaBytes represented by this object.
public double GigaBytes { get; }
Property Value
KibiBytes
Gets the number of KibiBytes represented by this object.
public double KibiBytes { get; }
Property Value
KiloBytes
Gets the number of KiloBytes represented by this object.
public double KiloBytes { get; }
Property Value
MebiBytes
Gets the number of MebiBytes represented by this object.
public double MebiBytes { get; }
Property Value
MegaBytes
Gets the number of MegaBytes represented by this object.
public double MegaBytes { get; }
Property Value
One
Gets the byte value 1
.
public static ByteSize One { get; }
Property Value
TebiBytes
Gets the number of TebiBytes represented by this object.
public double TebiBytes { get; }
Property Value
TeraBytes
Gets the number of TeraBytes represented by this object.
public double TeraBytes { get; }
Property Value
Zero
Gets the byte value 0
.
public static ByteSize Zero { get; }
Property Value
Methods
CompareTo(ByteSize)
public int CompareTo(ByteSize other)
Parameters
other
ByteSize
Returns
Deconstruct(out long)
public void Deconstruct(out long ByteCount)
Parameters
ByteCount
long
Equals(ByteSize)
public bool Equals(ByteSize other)
Parameters
other
ByteSize
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
obj
object
Returns
FromBytes(long)
Returns new ByteSize with value
bytes
public static ByteSize FromBytes(long value)
Parameters
value
longNumber of bytes
Returns
FromGibiBytes(double)
Returns new ByteSize with value
gibi-bytes
public static ByteSize FromGibiBytes(double value)
Parameters
value
doubleNumber of gibi-bytes
Returns
FromGigaBytes(double)
Returns new ByteSize with value
giga-bytes
public static ByteSize FromGigaBytes(double value)
Parameters
value
doubleNumber of giga-bytes
Returns
FromKibiBytes(double)
Returns new ByteSize with value
kibi-bytes
public static ByteSize FromKibiBytes(double value)
Parameters
value
doubleNumber of kibi-bytes
Returns
FromKiloByte(double)
Returns new ByteSize with value
kilo-bytes
public static ByteSize FromKiloByte(double value)
Parameters
value
doubleNumber of kilo-bytes
Returns
FromMebiBytes(double)
Returns new ByteSize with value
mebi-bytes
public static ByteSize FromMebiBytes(double value)
Parameters
value
doubleNumber of mebi-bytes
Returns
FromMegaBytes(double)
Returns new ByteSize with value
mega-bytes
public static ByteSize FromMegaBytes(double value)
Parameters
value
doubleNumber of mega-bytes
Returns
FromTebiBytes(double)
Returns new ByteSize with value
gibi-bytes
public static ByteSize FromTebiBytes(double value)
Parameters
value
doubleNumber of tebi-bytes
Returns
FromTeraBytes(double)
Returns new ByteSize with value
tera-bytes
public static ByteSize FromTeraBytes(double value)
Parameters
value
doubleNumber of tera-bytes
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
Returns the string representation for the current byte size
public override string ToString()
Returns
ToString(Measure)
Returns the string representation for the current byte size as measure
public string ToString(ByteSize.Measure measure)
Parameters
Returns
ToString(string?)
public string ToString(string? format)
Parameters
format
string
Returns
ToString(string?, IFormatProvider?)
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
format
stringformatProvider
IFormatProvider
Returns
TryFormat(Span<byte>, out int, ReadOnlySpan<char>, IFormatProvider?)
public bool TryFormat(Span<byte> utf8Destination, out int bytesWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
utf8Destination
Span<byte>bytesWritten
intformat
ReadOnlySpan<char>provider
IFormatProvider
Returns
Operators
explicit operator ByteSize(byte)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(byte value)
Parameters
value
byte
Returns
explicit operator ByteSize(short)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(short value)
Parameters
value
short
Returns
explicit operator ByteSize(int)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(int value)
Parameters
value
int
Returns
explicit operator ByteSize(long)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(long value)
Parameters
value
long
Returns
explicit operator ByteSize(sbyte)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(sbyte value)
Parameters
value
sbyte
Returns
explicit operator ByteSize(ushort)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(ushort value)
Parameters
value
ushort
Returns
explicit operator ByteSize(uint)
Returns new ByteSize with value
bytes
public static explicit operator ByteSize(uint value)
Parameters
value
uint
Returns
operator *(long, ByteSize)
public static ByteSize operator *(long left, ByteSize right)
Parameters
Returns
Explicit Interface Implementations
operator +(ByteSize, ByteSize)
static ByteSize operator +(ByteSize left, ByteSize right)
Parameters
Returns
operator --(ByteSize)
static ByteSize operator --(ByteSize value)
Parameters
value
ByteSize
Returns
operator /(ByteSize, double)
static ByteSize operator /(ByteSize left, double right)
Parameters
Returns
operator /(ByteSize, long)
static ByteSize operator /(ByteSize left, long right)
Parameters
Returns
operator ==(ByteSize, ByteSize)
static bool operator ==(ByteSize left, ByteSize right)
Parameters
Returns
operator >(ByteSize, ByteSize)
static bool operator >(ByteSize left, ByteSize right)
Parameters
Returns
operator >=(ByteSize, ByteSize)
static bool operator >=(ByteSize left, ByteSize right)
Parameters
Returns
operator ++(ByteSize)
static ByteSize operator ++(ByteSize value)
Parameters
value
ByteSize
Returns
operator !=(ByteSize, ByteSize)
static bool operator !=(ByteSize left, ByteSize right)
Parameters
Returns
operator <(ByteSize, ByteSize)
static bool operator <(ByteSize left, ByteSize right)
Parameters
Returns
operator <=(ByteSize, ByteSize)
static bool operator <=(ByteSize left, ByteSize right)
Parameters
Returns
operator *(ByteSize, long)
static ByteSize operator *(ByteSize left, long right)
Parameters
Returns
operator -(ByteSize, ByteSize)
static ByteSize operator -(ByteSize left, ByteSize right)