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 Core:不支援從另一個執行緒讀取或寫入執行緒的文化特性。.NET Core only: Reading or writing the culture of a thread from another thread is not supported.


下列範例顯示的執行緒語句,可讓 Windows Forms 應用程式的使用者介面顯示在 [控制台] 中設定的文化特性。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 上,如果執行緒嘗試在不同的執行緒上讀取或寫入 CurrentCulture 屬性,則會擲回 InvalidOperationExceptionOn .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 類別的行為已變更:當它代表中性文化特性時,其屬性值(特別是 CalendarCompareInfoDateTimeFormatNumberFormatTextInfo 屬性)現在會反映特定的文化特性,也就是與中性文化特性相關聯。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.


用於設定屬性。for setting the property. 相關聯的列舉: ControlThreadAssociated enumeration: ControlThread