Läs på engelska Redigera

Dela via


TimeOnly.TryParseExact Method

Definition

Overloads

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(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(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>, String[], IFormatProvider, DateTimeStyles, TimeOnly)

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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, string?[]? formats, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

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

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

TryParseExact(String, String[], TimeOnly)

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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(string? s, string?[]? formats, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

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

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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(string? s, string? format, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

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

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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, string?[]? formats, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

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

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

TryParseExact(String, String, TimeOnly)

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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(string? s, string? format, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10

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

Source:
TimeOnly.cs
Source:
TimeOnly.cs
Source:
TimeOnly.cs

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(string? s, string?[]? formats, IFormatProvider? provider, System.Globalization.DateTimeStyles style, out TimeOnly result);

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

true if s was converted successfully; otherwise, false.

Applies to

.NET 10 och andra versioner
Produkt Versioner
.NET 6, 7, 8, 9, 10