Thread.CurrentUICulture 속성

정의

리소스 관리자가 런타임에 문화권 관련 리소스를 찾기 위해 사용하는 현재 문화권을 가져오거나 설정합니다.

public:
 property System::Globalization::CultureInfo ^ CurrentUICulture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };
public System.Globalization.CultureInfo CurrentUICulture { get; set; }
member this.CurrentUICulture : System.Globalization.CultureInfo with get, set
Public Property CurrentUICulture As CultureInfo

속성 값

CultureInfo

현재 문화를 나타내는 개체입니다.

예외

속성이 null로 설정됩니다.

속성이 리소스 파일을 찾는 데 사용할 수 없는 문화권 이름으로 설정되어 있습니다. 리소스 파일 이름에는 문자, 숫자, 하이픈 또는 밑줄만 포함해야 합니다.

.NET Core 및 .NET 5 +만 해당: 다른 스레드에서 스레드의 문화권을 읽거나 쓰는 것은 지원 되지 않습니다.

예제

다음 예제에서는 현재 스레드의 UI 문화권 언어가 프랑스어 인지 여부를 확인 합니다. 그렇지 않으면 현재 스레드의 UI 문화권을 영어 (미국)로 설정 합니다.

using System;
using System.Globalization;
using System.Threading;

public class Example
{
   public static void Main()
   {
      // Change the current culture if the language is not French.
      CultureInfo current = Thread.CurrentThread.CurrentUICulture;
      if (current.TwoLetterISOLanguageName != "fr") {
         CultureInfo newCulture = CultureInfo.CreateSpecificCulture("en-US");
         Thread.CurrentThread.CurrentUICulture = newCulture;
         // Make current UI culture consistent with current culture.
         Thread.CurrentThread.CurrentCulture = newCulture;
      }
      Console.WriteLine("The current UI culture is {0} [{1}]",
                        Thread.CurrentThread.CurrentUICulture.NativeName,
                        Thread.CurrentThread.CurrentUICulture.Name);
      Console.WriteLine("The current culture is {0} [{1}]",
                        Thread.CurrentThread.CurrentUICulture.NativeName,
                        Thread.CurrentThread.CurrentUICulture.Name);
   }
}
// The example displays the following output:
//     The current UI culture is English (United States) [en-US]
//     The current culture is English (United States) [en-US]
Imports System.Globalization
Imports System.Threading

Module Example
   Public Sub Main()
      ' Change the current culture if the language is not French.
      Dim current As CultureInfo = Thread.CurrentThread.CurrentUICulture
      If current.TwoLetterISOLanguageName <> "fr" Then
         Dim newCulture As CultureInfo = CultureInfo.CreateSpecificCulture("en-US")
         Thread.CurrentThread.CurrentUICulture = newCulture
         ' Make current UI culture consistent with current culture.
         Thread.CurrentThread.CurrentCulture = newCulture
      End If
      Console.WriteLine("The current UI culture is {0} [{1}]",
                        Thread.CurrentThread.CurrentUICulture.NativeName,
                        Thread.CurrentThread.CurrentUICulture.Name)
      Console.WriteLine("The current culture is {0} [{1}]",
                        Thread.CurrentThread.CurrentUICulture.NativeName,
                        Thread.CurrentThread.CurrentUICulture.Name)
   End Sub
End Module
' The example displays output like the following:
'     The current UI culture is English (United States) [en-US]
'     The current culture is English (United States) [en-US]

다음 코드 예제에서는 Windows Forms의 사용자 인터페이스가 제어판에 설정 된 문화권에 표시 될 수 있도록 하는 스레딩 문을 보여 줍니다. 추가 코드가 필요 합니다.

#using <system.dll>
#using <System.Drawing.dll>
#using <system.windows.forms.dll>

using namespace System;
using namespace System::Threading;
using namespace System::Windows::Forms;
ref class UICulture: public 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.
   }
};


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

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

        ' Add additional code.
    End Sub

    Shared Sub Main()
        Application.Run(New UICulture())
    End Sub
End Class

설명

UI 문화권은 애플리케이션 사용자 입력 및 출력을 지원 하며 기본적으로 운영 체제 문화권과 동일 리소스를 지정 합니다. 참조 된 CultureInfo 문화권 이름 및 식별자, 고정, 중립 및 특정 문화권 간의 차이점에 대해 자세히 알아보려면 클래스 및 애플리케이션 도메인과 스레드 방식으로 문화권 정보에 영향을 줍니다. CultureInfo.CurrentUICulture스레드의 기본 UI 문화권이 결정 되는 방법에 대 한 자세한 내용은 속성을 참조 하세요.

중요

CurrentUICulture속성이 현재 스레드가 아닌 다른 스레드에서 사용 될 경우 안정적으로 작동 하지 않습니다. .NET Framework에서 속성을 읽는 것은 안정적 이지만 현재 스레드 이외의 스레드에 대 한 설정은 설정할 수 없습니다. .NET Core에서 InvalidOperationException 스레드가 CurrentUICulture 다른 스레드의 속성을 읽거나 쓰려고 하면이 throw 됩니다. 속성을 사용 하 여 CultureInfo.CurrentUICulture 현재 문화권을 검색 하 고 설정 하는 것이 좋습니다.

CultureInfo이 속성에서 반환 되는는 중립 문화권이 될 수 있습니다. 중립 문화권은, 및과 같은 서식 지정 메서드와 함께 사용 하면 안 됩니다 String.Format(IFormatProvider, String, Object[]) DateTime.ToString(String, IFormatProvider) Convert.ToString(Char, IFormatProvider) . 메서드를 사용 CultureInfo.CreateSpecificCulture 하 여 특정 문화권을 가져오거나 속성을 사용 합니다 CurrentCulture .

적용 대상