IFormatProvider and Globalization
So, as I continue through with FXCop (yes, I never really dinked with this tool before yesterday, sue me), I find odd little things that make absolutely no sense until I dig down (and even then, perhaps no sense).
One of those? The touchiness of “Specify IFormatProvider”:
“Students.get_AdmissionDate():DateTime makes a call to System.Convert.ToDateTime(System.String) that does not explicitly provide an IFormatProvider. This should be replaced with a call to System.Convert.ToDateTime(System.String,System.IFormatProvider).”
Okay, I get that. I get that Dates and Times are sensitive to the globalization stuff. I can fix that by modifying my conversion helper function to.
// Note: null can be used for the culture for Current.
Now, what I don’t get is when it throws it for Integers. Currency, yeah, definately. Decimals—yeah, I see that. DateTime, sure, why not. But integers? A whole number without much flair… <boggle />