I have the following line of code in an existing implementation
DateTime.TryParseExact( "15/11/2021 00:00:00", "dd/MM/yyyy HH:mm:ss", null, DateTimeStyles.None, out maturityDate);
which returns false , which means that the past line cannot be parsed. It was really amazing for me, because here the picture seems accurate. According to MSDN, a null value in the third parameter means that the current culture information will be used (I assume it is Thread.CurrentThread.CurrentCulture ).
Thread.CurrentThread.CurrentCulture in the en-US viewport, but the culture information instance was changed somewhere in the code later (date time formats or something else).
When I go through CultureInfo.InvariantCulture or new CultureInfo("en-US") , everything is fine.
Can someone say what causes TryParseExact here when null passed? Such questions did not give me any clue.
source share