Parse and TryParse with culture info C# with Example



Parse and TryParse with culture info C# with Example

You might want to use it when parsing DateTimes from different cultures (languages), following example parses 
Dutch date. 
 

DateTime dateResult; 
var dutchDateString = "31 oktober 1999 04:20"; 
var dutchCulture = CultureInfo.CreateSpecificCulture("nl-NL"); 
DateTime.TryParse(dutchDateString, dutchCulture, styles, out dateResult); 
// output  {31/10/1999  04:20:00} 
Example of Parse: 
DateTime.Parse(dutchDateString, dutchCulture) 
//  output  {31/10/1999  04:20:00} 

0 Comment's

Comment Form