public static BinarySize Parse(
ReadOnlySpan<char> s,
IFormatProvider? provider
)
Public Shared Function Parse (
s As ReadOnlySpan(Of Char),
provider As IFormatProvider
) As BinarySize
public:
static BinarySize Parse(
ReadOnlySpan<wchar_t> s,
IFormatProvider^ provider
)
static member Parse :
s : ReadOnlySpan<char> *
provider : IFormatProvider -> BinarySize
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 any surrounding whitespace is ignored.
The units listed above are the default, invariant units based on the English language. You can parse localized units by using the BinaryUnitInfo class with the provider parameter, either directly or together with a CultureInfo object through the CultureInfoExtensionsWithBinaryUnitInfo(CultureInfo, BinaryUnitInfo) method.
The case of the units in s is ignored by default. Use the BinaryUnitInfoCompareOptions property to customize how units are matched.
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 Parse(ReadOnlySpanChar, BinarySizeOptions, NumberStyles, IFormatProvider) method.
FormatException | s is not in the correct format. |
OverflowException | s is not representable as a BinarySize. |