BinarySizeTryParse(ReadOnlySpanChar, IFormatProvider, BinarySize) Method

Tries to parse a span of characters into a BinarySize structure.

Definition

Namespace: Ookii
Assembly: Ookii.BinarySize (in Ookii.BinarySize.dll) Version: 1.0.0+877c9712c6435bf9adfdb0683d7a434c5604a8f2
C#
public static bool TryParse(
	ReadOnlySpan<char> s,
	IFormatProvider? provider,
	out BinarySize result
)

Parameters

s  ReadOnlySpanChar
The span of characters to parse.
provider  IFormatProvider
An object that provides culture-specific formatting information about s.
result  BinarySize
When this method returns, contains the result of successfully parsing s, or an undefined value on failure.

Return Value

Boolean
if s was successfully parsed; otherwise, .

Implements

ISpanParsableTSelfTryParse(ReadOnlySpanChar, IFormatProvider, TSelf)

Remarks

The input must contain a number, followed by one of the following units: "B", "KB", "KiB", "MB", "MiB", "GB", "GiB", "TB", "TiB", "PB", "PiB", "EB", or "EiB". The "B" may be omitted, and the casing of the unit and any surrounding whitespace is ignored.

This method uses the definition that "1 KB" == 1024 bytes, identical to "1 KiB", and "1 MB" == "1 MiB" == 1048576 bytes, and so on. To use the IEC standard where SI prefixes are treated as powers of ten, use the TryParse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider, BinarySize) method.

See Also