Double.Parse - Internationalization problem

前端 未结 6 661
故里飘歌
故里飘歌 2020-12-17 10:04

This is driving me crazy. I have the following string in a ASP.NET 2.0 WebForm Page

string s = \"0.009\";

Simple enough. Now, if my culture

6条回答
  •  攒了一身酷
    2020-12-17 10:55

    You're mistaking parsing and formatting. You get 9 instead of .009 the first time because you take a string that is formated in a .-based culture and parse it using a ,-based culture. You need to parse it using whatever culture it was created with and then format it using whatever culture you want for display.

提交回复
热议问题