C#

C#

Made by DeepSource

Missing Culture-related information when parsing Date and Time-s CS-W1092

Bug risk
Critical

Failing to pass Culture-related information when parsing Date and Time-s prompts the runtime to use the host system's information. If your application runs on systems that are spread across different regions with different locales, this can cause problems with the formatting. One such example is DD/MM and MM/DD. To avoid such pitfalls, always pass in the Culture-related information.

Bad Practice

var parsed = DateTime.Parse(s);

Recommended

var parsed = DateTime.Parse(s, new CultureInfo("en-US"));