German UI Culture de-DE decimal changing to comma value issue in asp.net

后端 未结 4 958
离开以前
离开以前 2021-01-06 04:15

I am using german UI Culture in my asp.net application. I am changing my application\'s UI culture based on the language selected in the dropdown, on dropdown selected inde

相关标签:
4条回答
  • 2021-01-06 04:37

    Thread.CurrentUICulture is intended to be used for User Interface, it's the language used to display text, orientation and so on.
    Thread.CurrentCulture is intended to be used for parsing/formatting stuffs. Date and time, numbers and string comparison (for example).

    If you want to change only UI language (and to keep everything else with the culture of your web server) you have to modify only Thread.CurrentUICulture.

    0 讨论(0)
  • 2021-01-06 04:50

    This behavior is correct for German. However, you might want to use . When serializing to XML, inserting to database, etc. for doing so you can format using invariant culture. You can learn more about Invariant Culture in the following link: What does CultureInfo.InvariantCulture mean

    0 讨论(0)
  • 2021-01-06 04:57

    In german culture Decimal is denoated by ","

    German culture uses "." as a group separator and "," as the decimal separator

    Refer wiki link

    0 讨论(0)
  • 2021-01-06 05:02

    you can change number format info as per below code

    Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
    

    try below code for parsing the decimal values as per culture.

    string str = "50,3";
    Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
    double d = double.Parse(str, Thread.CurrentThread.CurrentCulture.NumberFormat);
    

    it gives result d = 50.3

    0 讨论(0)
提交回复
热议问题