Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Thread.CurrentCulture Property

 

Gets or sets the culture for the current thread.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public CultureInfo CurrentCulture {
	get;
	[SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)]
	set;
}

Property Value

Type: System.Globalization.CultureInfo

An object that represents the culture for the current thread.

Exception Condition
ArgumentNullException

The property is set to null.

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. 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. See the CultureInfo.CurrentCulture property to learn how a thread's default culture is determined, and how users set culture information for their computers.

Beginning with the .NET Framework 4, you can set the CurrentCulture property to a neutral culture. 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. In earlier versions of the .NET Framework, the CurrentCulture property threw a NotSupportedException exception when a neutral culture was assigned.

The following code example shows the threading statement that allows the user interface of a Windows Forms to display in the culture that is set in Control Panel. Additional code is needed.

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 = 
            Thread.CurrentThread.CurrentCulture;

        // Add additional code.
    }

    static void Main()
    {
        Application.Run(new UICulture());
    }
}

SecurityPermission

for setting the property. Associated enumeration: SecurityPermissionFlag.ControlThread

.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2016 Microsoft