繁体   English   中英

如何更改 .NET Core 3.1 的语言环境?

[英]How to change Locale of .NET Core 3.1?

有没有办法更改 .Net Core 3.1 的语言环境? 也许通过 dotnet CLI? 现在它使用,代替小数点. .

我正在使用 .Net Core 3.1 开发控制台应用程序。

在您的应用程序启动时:

System.Threading.Thread.CurrentThread.CurrentCulture 
  = System.Globalization.CultureInfo.GetCultureInfo("en");

"fr""the culture of your choice"

或者直接切入正题(我认为不太好):

System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyGroupSeparator="";
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator="";
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator=".";
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator=".";

您应该像这里一样在Main方法中执行此操作

CultureInfo.CurrentCulture = new CultureInfo("th-TH", false);
CultureInfo.CurrentUICulture = new CultureInfo( "ja-JP", false);

CultureInfo对象是这样做的首选方式,而不是CurrentThread 请参阅 Microsoft 文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM