当Windows使用阿拉伯语UI时C#在文件中写入英文数字

发布于 2024-10-18 02:58:07 字数 336 浏览 7 评论 0原文

我的窗户使用阿拉伯语。 当我在文件中写入数字时,它以阿拉伯语格式显示, 但我需要以英文格式编写,

尽管我在写入文件之前使用了这两行:

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

并且我使用 string.Format(new CultureInfo("en-US") , myNumbers)

为什么会发生这种情况?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千寻… 2024-10-25 02:58:07

尝试指定数字格式:

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

当我在美国英语 Windows 7 计算机上运行以下代码时,我得到相同的结果。您期待什么格式?

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文