Parse static 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) {
  var output = TryParse(value);
  if (output.isExceptionThrown == true) {
    throw FormatException('Value is not in the correct format');
  }
  return output.byteSizeObj;
}