Skip to content

Commit 1def2ee

Browse files
authored
Update StringToParse section
The information relating to the `DateTimeFormatInfo` object is important enough to call out earlier here in the docs...some of this information is later referenced only when referring to ParseExact, but this small addition is helpful to immediately note that the full DateTimeFormatInfo object is used as the default parsing, which would include formatting patterns.
1 parent f532ec7 commit 1def2ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xml/System/DateTime.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5091,7 +5091,7 @@ juillet 2009
50915091

50925092
<a name="StringToParse"></a>
50935093
### The string to parse
5094-
The <xref:System.DateTime.Parse%2A> method tries to convert the string representation of a date and time value to its <xref:System.DateTime> equivalent. It tries to parse the input string completely without throwing a <xref:System.FormatException> exception.
5094+
The <xref:System.DateTime.Parse%2A> method tries to convert the string representation of a date and time value to its <xref:System.DateTime> equivalent. It tries to parse the input string completely without throwing a <xref:System.FormatException> exception. The string is parsed using formatting information in the current <xref:System.Globalization.DateTimeFormatInfo> object, which is supplied implicitly by the current thread culture.
50955095

50965096
> [!IMPORTANT]
50975097
> If the parsing operation fails because of an unrecognized string format, the <xref:System.DateTime.Parse%2A> method throws a <xref:System.FormatException>, whereas the <xref:System.DateTime.TryParse%2A> method returns `false`. Because exception handling can be expensive, you should use <xref:System.DateTime.Parse%2A> when the parsing operation is expected to succeed because the input source is trusted. <xref:System.DateTime.TryParse%2A> is preferable when parsing failures are likely, particularly because an input source is not trusted, or you have reasonable default values to substitute for strings that do not parse successfully.

0 commit comments

Comments
 (0)