.NET Framework Class Library for Silverlight
CultureInfo..::.CurrentCulture Property

Gets the CultureInfo object that represents the culture used by the current thread.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
Syntax

Visual Basic (Declaration)
Public Shared ReadOnly Property CurrentCulture As CultureInfo
    Get
Visual Basic (Usage)
Dim value As CultureInfo

value = CultureInfo.CurrentCulture
C#
public static CultureInfo CurrentCulture { get; }

Property Value

Type: System.Globalization..::.CultureInfo
The object that represents the culture used by the current thread.
Remarks

The culture is a property of the executing thread. This read-only property returns Thread..::.CurrentCulture. To change the culture used by a thread, assign the new culture to the Thread..::.CurrentCulture property.

Examples

The following example demonstrates how to change the CurrentCulture and CurrentUICulture of the current thread.

Visual Basic
Imports System.Globalization
Imports System.Threading

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' Displays the name of the CurrentCulture of the current thread.
      outputBlock.Text += String.Format("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name) & vbCrLf

      ' 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) & vbCrLf

      ' Displays the name of the CurrentUICulture of the current thread.
      outputBlock.Text += String.Format("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name) & vbCrLf

      ' 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) & vbCrLf
   End Sub
End Class
'This code produces the following output:
'       CurrentCulture is en-US.
'       CurrentCulture is now th-TH.
'       CurrentUICulture is en-US.
'       CurrentUICulture is now ja-JP.
C#
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.
*/
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Tags :


Page view tracker