TimeOnly.TryParse Method

Definition

Overloads

TryParse(ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParse(String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

TryParse(String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

TryParse(ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

public:
 static bool TryParse(ReadOnlySpan<char> s, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParse (ReadOnlySpan<char> s, out TimeOnly result);
static member TryParse : ReadOnlySpan<char> * TimeOnly -> bool
Public Shared Function TryParse (s As ReadOnlySpan(Of Char), ByRef result As TimeOnly) As Boolean

Parameters

s
ReadOnlySpan<Char>

A span containing the characters representing the time to convert.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or MinValue if the conversion failed. The conversion fails if s is the empty string or does not contain a valid string representation of a time. This parameter is passed uninitialized.

Returns

Boolean

true if the conversion was successful; otherwise, false.

Applies to

TryParse(String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent and returns a value that indicates whether the conversion succeeded.

public:
 static bool TryParse(System::String ^ s, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParse (string? s, out TimeOnly result);
static member TryParse : string * TimeOnly -> bool
Public Shared Function TryParse (s As String, ByRef result As TimeOnly) As Boolean

Parameters

s
String

A string containing the time to convert.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or MinValue if the conversion failed. The conversion fails if s is an empty string or does not contain a valid string representation of a time. This parameter is passed uninitialized.

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to

TryParse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

public:
 static bool TryParse(ReadOnlySpan<char> s, IFormatProvider ^ provider, System::Globalization::DateTimeStyles style, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParse (ReadOnlySpan<char> s, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);
static member TryParse : ReadOnlySpan<char> * IFormatProvider * System.Globalization.DateTimeStyles * TimeOnly -> bool
Public Shared Function TryParse (s As ReadOnlySpan(Of Char), provider As IFormatProvider, style As DateTimeStyles, ByRef result As TimeOnly) As Boolean

Parameters

s
ReadOnlySpan<Char>

A string containing the characters that represent a time to convert.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of enumeration values that indicates the permitted format of s. A typical value to specify is None.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or MinValue if the conversion failed. The conversion fails if s is an empty string or does not contain a valid string representation of a date. This parameter is passed uninitialized.

Returns

Boolean

true ifs was converted successfully; otherwise, false.

Applies to

TryParse(String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

public:
 static bool TryParse(System::String ^ s, IFormatProvider ^ provider, System::Globalization::DateTimeStyles style, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParse (string? s, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);
static member TryParse : string * IFormatProvider * System.Globalization.DateTimeStyles * TimeOnly -> bool
Public Shared Function TryParse (s As String, provider As IFormatProvider, style As DateTimeStyles, ByRef result As TimeOnly) As Boolean

Parameters

s
String

A string containing the time to convert.

provider
IFormatProvider

The culture-specific formatting information about s.

style
DateTimeStyles

A bitwise combination of enumeration values that indicates the permitted format of s. A typical value to specify is None.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or MinValue if the conversion failed. The conversion fails if s is an empty string or does not contain a valid string representation of a time. This parameter is passed uninitialized.

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to