Skip to main content
Version: 4.0 (next)

Humanizer.ByteSizeExtensions

ByteSizeExtensions Class​

Provides extension methods for ByteSize

public static class ByteSizeExtensions

Inheritance System.Object → ByteSizeExtensions

Methods​

ByteSizeExtensions.Bits(this byte) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Bits(this double) Method​

Considers input as bits, including fractional values.

public static Humanizer.ByteSize Bits(this double input);
Parameters​

input System.Double

Returns​

ByteSize

Remarks​

Fractional values are preserved in Bytes. Bits rounds up to the nearest whole bit. For example, 2.5 bits produces 0.3125 bytes and a Bits value of 3.

ByteSizeExtensions.Bits(this int) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Bits(this long) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Bits(this sbyte) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Bits(this short) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Bits(this uint) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Bits(this ushort) Method​

Considers input as bits

public static Humanizer.ByteSize Bits(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Bytes(this byte) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Bytes(this double) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Bytes(this int) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Bytes(this long) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Bytes(this sbyte) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Bytes(this short) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Bytes(this uint) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Bytes(this ushort) Method​

Considers input as bytes

public static Humanizer.ByteSize Bytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this byte) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this double) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this int) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this long) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this sbyte) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this short) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this uint) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Exabytes(this ushort) Method​

Considers input as exabytes

public static Humanizer.ByteSize Exabytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this byte) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this double) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this int) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this long) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this sbyte) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this short) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this uint) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Gigabytes(this ushort) Method​

Considers input as gigabytes

public static Humanizer.ByteSize Gigabytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Humanize(this ByteSize, string) Method​

Turns a byte quantity into human readable form, eg 2 GB

public static string Humanize(this Humanizer.ByteSize input, string? format=null);
Parameters​

input ByteSize

format System.String

The string format to use

Returns​

System.String

ByteSizeExtensions.Humanize(this ByteSize, string, IFormatProvider) Method​

Turns a byte quantity into human readable form, eg 2 GB

public static string Humanize(this Humanizer.ByteSize input, string? format, System.IFormatProvider? formatProvider);
Parameters​

input ByteSize

format System.String

The string format to use

formatProvider System.IFormatProvider

The format provider to use

Returns​

System.String

ByteSizeExtensions.Humanize(this ByteSize, IFormatProvider) Method​

Turns a byte quantity into human readable form, eg 2 GB

public static string Humanize(this Humanizer.ByteSize input, System.IFormatProvider formatProvider);
Parameters​

input ByteSize

formatProvider System.IFormatProvider

The format provider to use

Returns​

System.String

ByteSizeExtensions.HumanizeComposite(this ByteSize, int, IFormatProvider, string, bool) Method​

Turns a byte quantity into a composite human-readable form using descending units, e.g. 10 KB 2 B.

public static string HumanizeComposite(this Humanizer.ByteSize input, int precision=2, System.IFormatProvider? formatProvider=null, string separator=" ", bool toWords=false);
Parameters​

input ByteSize

The byte quantity to humanize.

precision System.Int32

The maximum number of non-zero parts to return.

formatProvider System.IFormatProvider

The format provider to use. If null, the current culture is used.

separator System.String

The separator to use between parts.

toWords System.Boolean

Uses unit words instead of symbols if true.

Returns​

System.String
The composite byte quantity.

Exceptions​

System.ArgumentOutOfRangeException
precision is less than one.

System.ArgumentNullException
separator is null.

ByteSizeExtensions.HumanizeCompositeWithUnitSystem(this ByteSize, ByteSizeUnitSystem, int, IFormatProvider, string, bool) Method​

Turns a byte quantity into composite human-readable form using one explicit unit system.

public static string HumanizeCompositeWithUnitSystem(this Humanizer.ByteSize input, Humanizer.ByteSizeUnitSystem unitSystem, int precision=2, System.IFormatProvider? formatProvider=null, string separator=" ", bool toWords=false);
Parameters​

input ByteSize

The byte quantity to humanize.

unitSystem ByteSizeUnitSystem

The unit system to use.

precision System.Int32

The maximum number of non-zero parts to return.

formatProvider System.IFormatProvider

The provider used to format each numeric part and select localized unit words.

separator System.String

The separator to place between parts.

toWords System.Boolean

Uses localized unit words instead of canonical symbols when true.

Returns​

System.String
The composite humanized byte quantity.

Exceptions​

System.ArgumentOutOfRangeException
unitSystem is not defined or precision is less than one.

System.ArgumentNullException
separator is null.

ByteSizeExtensions.HumanizeWithUnitSystem(this ByteSize, ByteSizeUnitSystem, string, IFormatProvider) Method​

Turns a byte quantity into human-readable form using an explicit unit system.

public static string HumanizeWithUnitSystem(this Humanizer.ByteSize input, Humanizer.ByteSizeUnitSystem unitSystem, string? format=null, System.IFormatProvider? formatProvider=null);
Parameters​

input ByteSize

The byte quantity to humanize.

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.

formatProvider System.IFormatProvider

The provider used to format the numeric value.

Returns​

System.String
The humanized byte quantity.

Exceptions​

System.ArgumentOutOfRangeException
unitSystem is not defined.

System.FormatException
format is invalid, or selects a token not supported by the selected non-legacy system.

ByteSizeExtensions.Kilobytes(this byte) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this double) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this int) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this long) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this sbyte) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this short) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this uint) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Kilobytes(this ushort) Method​

Considers input as kilobytes

public static Humanizer.ByteSize Kilobytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this byte) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this double) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this int) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this long) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this sbyte) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this short) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this uint) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Megabytes(this ushort) Method​

Considers input as megabytes

public static Humanizer.ByteSize Megabytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this byte) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this double) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this int) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this long) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this sbyte) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this short) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this uint) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Pebibytes(this ushort) Method​

Considers input as pebibytes

public static Humanizer.ByteSize Pebibytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Per(this ByteSize, TimeSpan) Method​

Turns a quantity of bytes in a given interval into a rate that can be manipulated

public static Humanizer.ByteRate Per(this Humanizer.ByteSize size, System.TimeSpan interval);
Parameters​

size ByteSize

Quantity of bytes

interval System.TimeSpan

Interval to create rate for

Returns​

ByteRate

ByteSizeExtensions.Petabytes(this byte) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this double) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this int) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this long) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this sbyte) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this short) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this uint) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Petabytes(this ushort) Method​

Considers input as petabytes

public static Humanizer.ByteSize Petabytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this byte) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this byte input);
Parameters​

input System.Byte

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this double) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this double input);
Parameters​

input System.Double

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this int) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this int input);
Parameters​

input System.Int32

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this long) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this long input);
Parameters​

input System.Int64

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this sbyte) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this sbyte input);
Parameters​

input System.SByte

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this short) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this short input);
Parameters​

input System.Int16

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this uint) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this uint input);
Parameters​

input System.UInt32

Returns​

ByteSize

ByteSizeExtensions.Terabytes(this ushort) Method​

Considers input as terabytes

public static Humanizer.ByteSize Terabytes(this ushort input);
Parameters​

input System.UInt16

Returns​

ByteSize