I was playing around with the Datetime.ParseExact method, and it wants an IFormatProvider...
It works inputting null, but what exactly does it do?
The . NET Framework includes three format providers, all of which implement the IFormatProvider interface: NumberFormatInfo supplies numeric formatting information, such as the characters to use for decimal and group separators, and the spelling and placement of currency symbols in monetary values.
ParseExact(String, String, IFormatProvider) Converts the specified string representation of a date and time to its DateTime equivalent using the specified format and culture-specific format information. The format of the string representation must match the specified format exactly.
In adition to Ian Boyd's answer:
Also CultureInfo
implements this interface and can be used in your case. So you could parse a French date string for example; you could use
var ci = new CultureInfo("fr-FR"); DateTime dt = DateTime.ParseExact(yourDateInputString, yourFormatString, ci);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With