Läs på engelska Redigera

Dela via


DateOnly.Parse Method

Definition

Overloads

Parse(String)

Converts a string that contains string representation of a date to its DateOnly equivalent by using the conventions of the current culture.

Parse(ReadOnlySpan<Char>, IFormatProvider)

Parses a span of characters into a value.

Parse(String, IFormatProvider)

Parses a string into a value.

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

Converts a memory span that contains string representation of a date to its DateOnly equivalent by using culture-specific format information and a formatting style.

Parse(String, IFormatProvider, DateTimeStyles)

Converts a string that contains string representation of a date to its DateOnly equivalent by using culture-specific format information and a formatting style.

Parse(String)

Source:
DateOnly.cs
Source:
DateOnly.cs
Source:
DateOnly.cs

Converts a string that contains string representation of a date to its DateOnly equivalent by using the conventions of the current culture.

C#
public static DateOnly Parse(string s);

Parameters

s
String

The string that contains the string to parse.

Returns

An object that is equivalent to the date contained in s.

Exceptions

s does not contain a valid string representation of a date.

Applies to

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

Parse(ReadOnlySpan<Char>, IFormatProvider)

Source:
DateOnly.cs
Source:
DateOnly.cs
Source:
DateOnly.cs

Parses a span of characters into a value.

C#
public static DateOnly Parse(ReadOnlySpan<char> s, IFormatProvider? provider);

Parameters

s
ReadOnlySpan<Char>

The span of characters to parse.

provider
IFormatProvider

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

Returns

The result of parsing s.

Implements

Applies to

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

Parse(String, IFormatProvider)

Source:
DateOnly.cs
Source:
DateOnly.cs
Source:
DateOnly.cs

Parses a string into a value.

C#
public static DateOnly Parse(string s, IFormatProvider? provider);

Parameters

s
String

The string to parse.

provider
IFormatProvider

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

Returns

The result of parsing s.

Implements

Applies to

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

Parse(ReadOnlySpan<Char>, IFormatProvider, DateTimeStyles)

Source:
DateOnly.cs
Source:
DateOnly.cs
Source:
DateOnly.cs

Converts a memory span that contains string representation of a date to its DateOnly equivalent by using culture-specific format information and a formatting style.

C#
public static DateOnly Parse(ReadOnlySpan<char> s, IFormatProvider? provider = default, System.Globalization.DateTimeStyles style = System.Globalization.DateTimeStyles.None);

Parameters

s
ReadOnlySpan<Char>

The memory span that contains the string to parse.

provider
IFormatProvider

An object that supplies culture-specific format 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.

Returns

An object that is equivalent to the date contained in s, as specified by provider and styles.

Exceptions

s does not contain a valid string representation of a date.

Applies to

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

Parse(String, IFormatProvider, DateTimeStyles)

Source:
DateOnly.cs
Source:
DateOnly.cs
Source:
DateOnly.cs

Converts a string that contains string representation of a date to its DateOnly equivalent by using culture-specific format information and a formatting style.

C#
public static DateOnly Parse(string s, IFormatProvider? provider, System.Globalization.DateTimeStyles style = System.Globalization.DateTimeStyles.None);

Parameters

s
String

The string that contains the string to parse.

provider
IFormatProvider

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

style
DateTimeStyles

A bitwise combination of the enumeration values that indicates the style elements that can be present in s for the parse operation to succeed, and that defines how to interpret the parsed date. A typical value to specify is None.

Returns

An object that is equivalent to the date contained in s, as specified by provider and styles.

Exceptions

s does not contain a valid string representation of a date.

Applies to

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