Thread.CurrentCulture 属性


获取或设置当前线程的区域性。Gets or sets the culture for the current thread.

 property System::Globalization::CultureInfo ^ CurrentCulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };
public System.Globalization.CultureInfo CurrentCulture { get; set; }
member this.CurrentCulture : System.Globalization.CultureInfo with get, set
Public Property CurrentCulture As CultureInfo



表示当前线程的区域性的对象。An object that represents the culture for the current thread.


属性设置为 nullThe property is set to null.

仅限 .NET 5 及更高版本和 .NET Core:不支持从一个线程读取或写入另一个线程的区域性。.NET 5+ and .NET Core only: Reading or writing the culture of a thread from another thread is not supported.


下面的示例演示了线程语句,该语句允许 Windows 窗体应用程序的用户界面显示在控制面板中设置的区域性。The following example shows the threading statement that allows the user interface of a Windows Forms application to display in the culture that is set in Control Panel. 需要其他代码。Additional code is needed.

#using <system.dll>
#using <System.Drawing.dll>
#using <>

using namespace System;
using namespace System::Threading;
using namespace System::Windows::Forms;
ref class UICulture: public Form
      // Set the user interface to display in the
      // same culture as that set in Control Panel.
      Thread::CurrentThread->CurrentUICulture = Thread::CurrentThread->CurrentCulture;
      // Add additional code.

int main()
   Application::Run( gcnew UICulture );
using System;
using System.Threading;
using System.Windows.Forms;

class UICulture : Form
    public UICulture()
        // Set the user interface to display in the
        // same culture as that set in Control Panel.
        Thread.CurrentThread.CurrentUICulture = 

        // Add additional code.

    static void Main()
        Application.Run(new UICulture());
Imports System.Threading
Imports System.Windows.Forms

Public Class UICulture : Inherits Form
    Sub New()

        ' Set the user interface to display in the
        ' same culture as that set in Control Panel.
        Thread.CurrentThread.CurrentUICulture = _

        ' Add additional code.
    End Sub

    Shared Sub Main()
        Application.Run(New UICulture())
    End Sub
End Class


CultureInfo此属性返回的对象及其关联的对象确定日期、时间、数字、货币值的默认格式、文本的排序顺序、大小写约定和字符串比较。The CultureInfo object that is returned by this property, together with its associated objects, determine the default format for dates, times, numbers, currency values, the sorting order of text, casing conventions, and string comparisons. 请参见 CultureInfo 类以了解区域性名称和标识符、固定、非特定区域性和特定区域性之间的差异,以及区域性信息影响线程和应用程序域的方式。See the CultureInfo class to learn about culture names and identifiers, the differences between invariant, neutral, and specific cultures, and the way culture information affects threads and application domains. 请参阅 CultureInfo.CurrentCulture 属性以了解如何确定如何确定线程的默认区域性,以及用户如何为其计算机设置区域性信息。See the CultureInfo.CurrentCulture property to learn how a thread's default culture is determined, and how users set culture information for their computers.


CurrentCulture与当前线程以外的任何线程一起使用时,属性不能可靠地工作。The CurrentCulture property doesn't work reliably when used with any thread other than the current thread. 在 .NET Framework 中,读取属性是可靠的,但对于除当前线程之外的其他线程,其设置是可靠的。In .NET Framework, reading the property is reliable, although setting it for a thread other than the current thread is not. 在 .NET Core 中, InvalidOperationException 如果线程尝试在 CurrentCulture 另一个线程上读取或写入属性,则会引发。On .NET Core, an InvalidOperationException is thrown if a thread attempts to read or write the CurrentCulture property on a different thread. 建议使用 CultureInfo.CurrentCulture 属性来检索和设置当前区域性。We recommend that you use the CultureInfo.CurrentCulture property to retrieve and set the current culture.

从开始 .NET Framework 4.NET Framework 4 ,可以将 CurrentCulture 属性设置为非特定区域性。Beginning with the .NET Framework 4.NET Framework 4, you can set the CurrentCulture property to a neutral culture. 这是因为类的行为 CultureInfo 已更改:当它表示非特定区域性时,其属性值 (尤其如此), Calendar 此时,、、、 CompareInfo DateTimeFormat NumberFormatTextInfo 属性) 会反映与非特定区域性关联的特定区域性。This is because the behavior of the CultureInfo class has changed: When it represents a neutral culture, its property values (in particular, the Calendar, CompareInfo, DateTimeFormat, NumberFormat, and TextInfo properties) now reflect the specific culture that is associated with the neutral culture. 在 .NET Framework 的早期版本中,在 CurrentCulture NotSupportedException 分配非特定区域性时,属性引发异常。In earlier versions of the .NET Framework, the CurrentCulture property threw a NotSupportedException exception when a neutral culture was assigned.