此页面有用吗?
您对此内容的反馈非常重要。 请告诉我们您的想法。
更多反馈?
1500 个剩余字符
导出 (0) 打印
全部展开
信息
您所需的主题如下所示。但此主题未包含在此库中。

CultureInfo.CurrentCulture 属性

2013/12/13

获取表示当前线程使用的区域性的 CultureInfo 对象。

Namespace:  System.Globalization
程序集:  mscorlib(位于 mscorlib.dll 中)

public static CultureInfo CurrentCulture { get; }

属性值

类型: System.Globalization.CultureInfo
表示当前线程使用的区域性的对象。

区域性是当前执行线程的属性。此只读属性返回 Thread.CurrentCulture。若要更改线程使用的区域性,应将新区域性分配给 Thread.CurrentCulture 属性。

下面的示例阐释了如何更改当前线程的 CurrentCultureCurrentUICulture


using System;
using System.Globalization;
using System.Threading;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // Displays the name of the CurrentCulture of the current thread.
      outputBlock.Text += String.Format("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name) + "\n";

      // Changes the CurrentCulture of the current thread to th-TH.
      Thread.CurrentThread.CurrentCulture = new CultureInfo("th-TH");
      outputBlock.Text += String.Format("CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name) + "\n";

      // Displays the name of the CurrentUICulture of the current thread.
      outputBlock.Text += String.Format("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name) + "\n";

      // Changes the CurrentUICulture of the current thread to ja-JP.
      Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP");
      outputBlock.Text += String.Format("CurrentUICulture is now {0}.", CultureInfo.CurrentUICulture.Name) + "\n";
   }
}
/*
This code produces the following output:
   CurrentCulture is en-US.
   CurrentCulture is now th-TH.
   CurrentUICulture is en-US.
   CurrentUICulture is now ja-JP.
*/


Windows Phone OS

受以下版本支持: 8.0, 7.1, 7.0

Windows Phone

显示:
© 2015 Microsoft