开发者

C# Writing english numbers in file when windows use arabic UI

My windows use arabic language. When i write numbers in a file it appears in arabic format, but i need to write in english format,

although i use this two lines before 开发者_如何学编程writing to file:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

and i use string.Format(new CultureInfo("en-US") , myNumbers)

why this happen?


Try specifying a numeric format:

string.Format(new CultureInfo("en-US"), "{0:n}", myNumbers)

When I run the following code on my US English Windows 7 machine, I get identical results. What format are you expecting?

Console.WriteLine(String.Format(new CultureInfo("ar-SA"), "{0:n}", 123456789));
Console.WriteLine(String.Format(new CultureInfo("en-US"), "{0:n}", 123456789));

123,456,789.00

123,456,789.00

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜