Parse method

ByteSize Parse (
  1. String value
)

Returns a ByteSize object by parsing a string value and throws an exception if argument is incorrectly formatted.

ByteSize.Parse('1024MB') == ByteSize.FromMegaBytes(1024);

Implementation

static ByteSize Parse(String value) {
  ParseOutput output = TryParse(value);
  if (output.IsExceptionThrown == true) {
    throw FormatException('Value is not in the correct format');
  }
  return output.ByteSizeObj;
}