Method TryParseNumber
TryParseNumber(TypeCode, string?, NumberStyles?, IFormatProvider?, out object?)
Converts the string representation of a number to its number equivalent. A return value indicates whether the conversion succeeded or failed.
public static bool TryParseNumber(TypeCode typeCode, string? s, NumberStyles? style, IFormatProvider? provider, out object? result)
Parameters
typeCodeTypeCodeNumber type identifier.
sstringThe string to parse.
styleNumberStyles?A bitwise combination of NumberStyles values that indicates the permitted format of
s.providerIFormatProviderAn object that supplies culture-specific formatting information about
s.resultobjectWhen this method returns and if the conversion succeeded, contains a number equivalent of the numeric value or symbol contained in
s. Contains default value for the type if the conversion failed.
Returns
- bool
trueif s was converted successfully; otherwise,false.
Remarks
This method is equivalent of "TryParse" methods implemented in number types.