// Parses an integer from a String. Returns false rather // than throwing an exception if input is invalid. // public static bool TryParse([NotNullWhen(true)] string?s, out int result) { if (s == null) { result = 0; return(false); } return(Number.TryParseInt32IntegerStyle(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result) == Number.ParsingStatus.OK); }
public static bool TryParse(ReadOnlySpan <char> s, out int result) { return(Number.TryParseInt32IntegerStyle(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result) == Number.ParsingStatus.OK); }