CultureInfo.CurrentUICulture Właściwość

Definicja

Pobiera lub ustawia CultureInfo obiekt reprezentujący bieżącą kulturę interfejsu użytkownika używaną przez Resource Manager do wyszukiwania zasobów specyficznych dla kultury w czasie wykonywania.

C#
public static System.Globalization.CultureInfo CurrentUICulture { get; set; }
C#
public static System.Globalization.CultureInfo CurrentUICulture { get; }

Wartość właściwości

Kultura używana przez Resource Manager do wyszukiwania zasobów specyficznych dla kultury w czasie wykonywania.

Wyjątki

Właściwość jest ustawiona na null.

Właściwość jest ustawiona na nazwę kultury, której nie można użyć do zlokalizowania pliku zasobu. Nazwy plików zasobów mogą zawierać tylko litery, cyfry, łączniki lub podkreślenia.

Przykłady

W poniższym przykładzie kodu pokazano, jak zmienić CurrentCulture element i CurrentUICulture bieżącego wątku.

C#
using System;
using System.Globalization;
using System.Threading;

public class Example0
{
   public static void Main()
   {
      // Display the name of the current culture.
      Console.WriteLine("CurrentCulture is {0}.", CultureInfo.CurrentCulture.Name);

      // Change the current culture to th-TH.
      CultureInfo.CurrentCulture = new CultureInfo("th-TH", false);
      Console.WriteLine("CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name);

      // Display the name of the current UI culture.
      Console.WriteLine("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name);

      // Change the current UI culture to ja-JP.
      CultureInfo.CurrentUICulture = new CultureInfo( "ja-JP", false );
      Console.WriteLine("CurrentUICulture is now {0}.", CultureInfo.CurrentUICulture.Name);
   }
}
// The example displays the following output:
//       CurrentCulture is en-US.
//       CurrentCulture is now th-TH.
//       CurrentUICulture is en-US.
//       CurrentUICulture is now ja-JP.

Uwagi

Aby uzyskać więcej informacji na temat tego interfejsu API, zobacz Uwagi dotyczące dodatkowego interfejsu API dla elementu CultureInfo.CurrentUICulture.

Dotyczy

Produkt Wersje
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

Zobacz też