TimeOnly.TryParseExact Method

Definition

Overloads

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

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, TimeOnly)

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

TryParseExact(String, String[], TimeOnly)

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

TryParseExact(String, String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(ReadOnlySpan<Char>, String[], TimeOnly)

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

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

TryParseExact(String, String[], IFormatProvider, DateTimeStyles, TimeOnly)

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

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

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

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

Parameters

s
ReadOnlySpan<Char>

A span containing the time to convert.

format
ReadOnlySpan<Char>

The required format of s.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of one or more enumeration values that indicate the permitted format of s.

result
TimeOnly

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

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to

TryParseExact(ReadOnlySpan<Char>, String[], IFormatProvider, DateTimeStyles, TimeOnly)

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

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

Parameters

s
ReadOnlySpan<Char>

The span containing the time to parse.

formats
String[]

An array of allowable formats of s.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of enumeration values that defines how to interpret the parsed time. 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 TimeOnly.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

TryParseExact(String, 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 TryParseExact(System::String ^ s, cli::array <System::String ^> ^ formats, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParseExact (string? s, string?[]? formats, out TimeOnly result);
static member TryParseExact : string * string[] * TimeOnly -> bool
Public Shared Function TryParseExact (s As String, formats As String(), ByRef result As TimeOnly) As Boolean

Parameters

s
String

The string containing the time to parse.

formats
String[]

An array of allowable formats of s.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or TimeOnly.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

TryParseExact(String, String, IFormatProvider, DateTimeStyles, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format, culture-specific format information, and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

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

Parameters

s
String

A span containing the characters representing a time to convert.

format
String

The required format of s.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of one or more enumeration values that indicate the permitted format of s.

result
TimeOnly

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

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to

TryParseExact(ReadOnlySpan<Char>, String[], TimeOnly)

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

public:
 static bool TryParseExact(ReadOnlySpan<char> s, cli::array <System::String ^> ^ formats, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParseExact (ReadOnlySpan<char> s, string?[]? formats, out TimeOnly result);
static member TryParseExact : ReadOnlySpan<char> * string[] * TimeOnly -> bool
Public Shared Function TryParseExact (s As ReadOnlySpan(Of Char), formats As String(), ByRef result As TimeOnly) As Boolean

Parameters

s
ReadOnlySpan<Char>

The span containing the time to convert.

formats
String[]

An array of allowable formats of s.

result
TimeOnly

When this method returns, contains the TimeOnly value equivalent to the time contained in s, if the conversion succeeded, or TimeOnly.MinValue if the conversion failed. The conversion fails if the s parameter 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

TryParseExact(ReadOnlySpan<Char>, ReadOnlySpan<Char>, TimeOnly)

Converts the specified span representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

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

Parameters

s
ReadOnlySpan<Char>

A span containing the time to convert.

format
ReadOnlySpan<Char>

The required format of s.

result
TimeOnly

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

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to

TryParseExact(String, String, TimeOnly)

Converts the specified string representation of a time to its TimeOnly equivalent using the specified format and style. The format of the string representation must match the specified format exactly. The method returns a value that indicates whether the conversion succeeded.

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

Parameters

s
String

A string containing the time to convert.

format
String

The required format of s.

result
TimeOnly

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

Returns

Boolean

true if s was converted successfully; otherwise, false.

Applies to

TryParseExact(String, String[], IFormatProvider, DateTimeStyles, 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 TryParseExact(System::String ^ s, cli::array <System::String ^> ^ formats, IFormatProvider ^ provider, System::Globalization::DateTimeStyles style, [Runtime::InteropServices::Out] TimeOnly % result);
public static bool TryParseExact (string? s, string?[]? formats, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);
static member TryParseExact : string * string[] * IFormatProvider * System.Globalization.DateTimeStyles * TimeOnly -> bool
Public Shared Function TryParseExact (s As String, formats As String(), provider As IFormatProvider, style As DateTimeStyles, ByRef result As TimeOnly) As Boolean

Parameters

s
String

The string containing the time to parse.

formats
String[]

An array of allowable formats of s.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of enumeration values that defines how to interpret the parsed date. 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 TimeOnly.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