Best Way to Handle Numbers
Hello
Only now, I'm facing this kind of problem, i have a application that until now worked with two different cultures ENG and PT, i always knew this, and i manage to solve all problems related to parsing the numbers, but now i have to change the code, and "protect" the code to handle with others cultures.
So i need tips/best way to handle different cultures, and different database culture settings.
I think that i shouldn't limit the user, by setting the decimal, the grouping digit, the date time format, etc. . The application should accept the numbers in the user current culture. But this path forces me to putting everywhere the parse/tryparse method...
This is the way that i must follow?
Thanks
Re: Best Way to Handle Numbers
It may be. If you're accepting strings, after all, you need to retrieve their values some way or another, and so TryParse and Parse are ideal. In fact, it would be much easier than a manual conversion...
If you have type-restricted fields with matching UI elements, consider using type-specific controls like NumericUpDown and DateTimePicker, which automatically adapt based on the culture.