Thread.CurrentCulture 屬性


取得或設定目前執行緒的文化特性 (Culture)。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 form 應用程式的使用者介面顯示在 [控制台] 中設定的文化特性。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 如果執行緒嘗試讀取或寫入不同執行緒上的屬性,就會擲回 CurrentCultureOn .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 開始,您可以將屬性設定 CurrentCulture 為中性文化特性。Beginning with the .NET Framework 4, you can set the CurrentCulture property to a neutral culture. 這是因為類別的行為 CultureInfo 已變更:當它代表中立的文化特性時,其屬性值 (特別是、、 CalendarCompareInfo 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.