如何为整个C#应用程序的默认区域性信息

编程入门 行业动态 更新时间:2024-10-11 21:23:44
本文介绍了如何为整个C#应用程序的默认区域性信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要为这个类或整个应用程序的默认区域性的信息。

I want to set default culture info for that class or for entire application.

例如在土耳其3,2 =英文3.2

For example in Turkey 3,2 = in english 3.2

这样的应用程序使用我的地方,但我希望它为默认

so application uses my local but i want it to use as default

System.Globalization.CultureInfo.InvariantCulture

如何将其设置为默认为特定类或整个应用程序

How can i set it to that as default for that specific class or for entire application

推荐答案

不为整个应用程序或特定的类。

Not for entire application or particular class.

的CurrentUICulture和的CurrentCulture是每个线程可设置为这里讨论设置的CurrentCulture和的CurrentUICulture应用程序的 。你不能改变 InvariantCulture的所有

CurrentUICulture and CurrentCulture are settable per thread as discussed here Setting CurrentCulture and CurrentUICulture of an application. You can't change InvariantCulture at all.

示例代码更改为文化当前线程:

Sample code to change cultures for current thread:

CultureInfo ci = new CultureInfo(theCultureString); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci;

有关类,你可以设置/还原重要方法里面的文化,但它会显著安全使用适当的覆盖该拿文化作为一个参数最格式相关的方法:

For class you can set/restore culture inside critical methods, but it would be significantly safe to use appropriate overrides for most formatting related methods that take culture as one of arguments:

(3.3).ToString(new CultureInfo("fr-FR"))

更多推荐

如何为整个C#应用程序的默认区域性信息

本文发布于:2023-11-12 12:55:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区域性   何为   应用程序   信息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!