INumberBase<TSelf>.TryParse Method

Definition

Overloads

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, TSelf)

Tries to parse a span of characters into a value.

TryParse(String, NumberStyles, IFormatProvider, TSelf)

Tries to parse a string into a value.

TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, TSelf)

Tries to parse a span of UTF-8 characters into a value.

TryParse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider, TSelf)

Source:
INumberBase.cs
Source:
INumberBase.cs
Source:
INumberBase.cs

Tries to parse a span of characters into a value.

C#
public static abstract bool TryParse(ReadOnlySpan<char> s, System.Globalization.NumberStyles style, IFormatProvider? provider, out TSelf result);

Parameters

s
ReadOnlySpan<Char>

The span of characters to parse.

style
NumberStyles

A bitwise combination of number styles that can be present in s.

provider
IFormatProvider

An object that provides culture-specific formatting information about s.

result
TSelf

On return, contains the result of succesfully parsing s or an undefined value on failure.

Returns

true if s was successfully parsed; otherwise, false.

Exceptions

style is not a supported NumberStyles value.

Applies to

.NET 9 and other versions
Product Versions
.NET 7, 8, 9

TryParse(String, NumberStyles, IFormatProvider, TSelf)

Source:
INumberBase.cs
Source:
INumberBase.cs
Source:
INumberBase.cs

Tries to parse a string into a value.

C#
public static abstract bool TryParse(string? s, System.Globalization.NumberStyles style, IFormatProvider? provider, out TSelf result);

Parameters

s
String

The string to parse.

style
NumberStyles

A bitwise combination of number styles that can be present in s.

provider
IFormatProvider

An object that provides culture-specific formatting information about s.

result
TSelf

On return, contains the result of succesfully parsing s or an undefined value on failure.

Returns

true if s was successfully parsed; otherwise, false.

Exceptions

style is not a supported NumberStyles value.

Applies to

.NET 9 and other versions
Product Versions
.NET 7, 8, 9

TryParse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider, TSelf)

Source:
INumberBase.cs
Source:
INumberBase.cs

Tries to parse a span of UTF-8 characters into a value.

C#
public static virtual bool TryParse(ReadOnlySpan<byte> utf8Text, System.Globalization.NumberStyles style, IFormatProvider? provider, out TSelf result);

Parameters

utf8Text
ReadOnlySpan<Byte>

The span of UTF-8 characters to parse.

style
NumberStyles

A bitwise combination of number styles that can be present in utf8Text.

provider
IFormatProvider

An object that provides culture-specific formatting information about utf8Text.

result
TSelf

On return, contains the result of successfully parsing utf8Text or an undefined value on failure.

Returns

true if utf8Text was successfully parsed; otherwise, false.

Exceptions

style is not a supported NumberStyles value.

Applies to

.NET 9 and .NET 8
Product Versions
.NET 8, 9