Results 1 to 2 of 2

Thread: Best Way to Handle Numbers

  1. #1

    Thread Starter
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    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

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  2. #2
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width