Skip to content

M_CodeJam_Strings_StringExtensions_ToDateTimeInvariant

Andrew Koryavchenko edited this page Jun 17, 2018 · 2 revisions

StringExtensions.ToDateTimeInvariant Method

Converts the string representation of a number in a specified style and culture-invariant format to its DateTime equivalent. A return value indicates whether the conversion succeeded.

Namespace: CodeJam.Strings
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static Nullable<DateTime> ToDateTimeInvariant(
	this string str,
	DateTimeStyles dateStyle = DateTimeStyles.None
)

VB

<ExtensionAttribute>
Public Shared Function ToDateTimeInvariant ( 
	str As String,
	Optional dateStyle As DateTimeStyles = DateTimeStyles.None
) As Nullable(Of DateTime)

F#

[<ExtensionAttribute>]
static member ToDateTimeInvariant : 
        str : string * 
        ?dateStyle : DateTimeStyles 
(* Defaults:
        let _dateStyle = defaultArg dateStyle DateTimeStyles.None
*)
-> Nullable<DateTime> 

Parameters

 

str
Type: System.String
A string containing a number to convert. The string is interpreted using the style specified by dateStyle.
dateStyle (Optional)
Type: System.Globalization.DateTimeStyles
A bitwise combination of enumeration values that indicates the style elements that can be present in str. Default value is Integer.

Return Value

Type: Nullable(DateTime)
When this method returns, contains the DateTime value equivalent of the number contained in str, if the conversion succeeded, or null if the conversion failed. The conversion fails if the str parameter is null or String.Empty, is not in a format compliant withstyle, or represents a number less than MinValue or greater than MaxValue.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

StringExtensions Class
CodeJam.Strings Namespace

Clone this wiki locally