Citiți în limba engleză Editare

Partajați prin


TimeOnly.TryParse Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

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(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, TimeOnly)

Tries to parse a span of characters into a value.

TryParse(String, IFormatProvider, TimeOnly)

Tries to parse a string into a value.

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>, 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 array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

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

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 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 date. This parameter is passed uninitialized.

Returns

true ifs was converted successfully; otherwise, false.

Applies to

.NET 10 și alte versiuni
Produs Versiuni
.NET 6, 7, 8, 9, 10

TryParse(ReadOnlySpan<Char>, TimeOnly)

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

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

C#
public static bool TryParse(ReadOnlySpan<char> s, out TimeOnly result);

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

true if the conversion was successful; otherwise, false.

Applies to

.NET 10 și alte versiuni
Produs Versiuni
.NET 6, 7, 8, 9, 10

TryParse(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.

C#
public static bool TryParse(string? s, out TimeOnly result);

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 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 și alte versiuni
Produs Versiuni
.NET 6, 7, 8, 9, 10

TryParse(ReadOnlySpan<Char>, IFormatProvider, TimeOnly)

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

Tries to parse a span of characters into a value.

C#
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out TimeOnly result);

Parameters

s
ReadOnlySpan<Char>

A span of characters to parse.

provider
IFormatProvider

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

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

true if s was successfully parsed; otherwise, false.

Applies to

.NET 10 și alte versiuni
Produs Versiuni
.NET 7, 8, 9, 10

TryParse(String, IFormatProvider, TimeOnly)

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

Tries to parse a string into a value.

C#
public static bool TryParse(string? s, IFormatProvider? provider, out TimeOnly result);

Parameters

s
String

A string to parse.

provider
IFormatProvider

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

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

true if s was parsed successfully; otherwise, false.

Applies to

.NET 10 și alte versiuni
Produs Versiuni
.NET 7, 8, 9, 10

TryParse(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 using the specified array of formats, culture-specific format information and style, and returns a value that indicates whether the conversion succeeded.

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

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 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 și alte versiuni
Produs Versiuni
.NET 6, 7, 8, 9, 10