문화와 UICulture의 차이점은 무엇입니까?
누군가 .NET 프레임 워크 의 차이점 Culture
과 UICulture
.NET 프레임 워크 의 차이점에 대해 조금 더 많은 정보를 제공 할 수 있습니까? 그들이 무엇을하고 언제 무엇을 사용해야합니까?
Culture
문화 종속 데이터 (날짜, 통화, 숫자 등)가 표시되는 방식에 영향을줍니다. 다음은 몇 가지 예입니다.
var date = new DateTime(2000, 1, 2);
var number = 12345.6789;
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
Console.WriteLine(date); // 02.01.2000 00:00:00
Console.WriteLine(number.ToString("C")); // 12.345,68 €
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-CA");
Console.WriteLine(date); // 2000-01-02 00:00:00
Console.WriteLine(number.ToString("C")); // 12 345,68 $
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Console.WriteLine(date); // 1/2/2000 12:00:00 AM
Console.WriteLine(number.ToString("C")); // $12,345.68
문화는 또한 같은 방식으로 사용자 입력의 구문 분석에 영향을줍니다.
const string numberString = "12.345,68";
decimal money;
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
money = decimal.Parse(numberString); // OK!
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
money = decimal.Parse(numberString); // FormatException is thrown, TryParse would return false
구문 분석이 성공 하지만 결과가 예상 과 다른 경우에주의하십시오 .
const string numberString = "12.345";
decimal money;
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
money = decimal.Parse(numberString); // 12345
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
money = decimal.Parse(numberString); // 12.345, where the . is a decimal point
UICulture
응용 프로그램에서로드 할 리소스 파일 (Resources. lang .resx)에 영향을줍니다 .
So to load German resources (presumably localized text) you would set UICulture
to the German culture and to display German formatting (without any impact on which resources are loaded) you would set Culture
.
Culture and UICulture
Values are pairs of two-letter strings, the first is for defining language and the second for defining the region. Example:
en-GB
here en
represents English
and GB
represents Great Briton
en-US
here en
represents English
and US
represents United States
Use Culture
for Culture dependent functions like date, time. and UICulture
is for correct resource file loading.
Just a small matter to consider in addition to @Vache's awesome explanation: You can set both UICulture and Culture at (page level and application level).
In order to set them at application level, simply add globalization session in web.config
e.g. <globalization uiCulture="es" culture="es-MX" />
And to set them at the page level, which is good to add on a specific (individual) page, set the Culture and UICulture attributes within @ page directive
e.g. <%@ Page UICulture="es" Culture="es-MX" %>
The UICulture property might change for each Web browser, whereas the Culture stays constant.
The Culture value can be set to specific cultures only, such as en-US or en-GB. This prevents the requirement to identify the correct currency symbol to use for en, where en-US and en-GB have different currency symbols. Users can set the UI culture and culture in their browsers.
참고URL : https://stackoverflow.com/questions/9507582/what-is-the-difference-between-culture-and-uiculture
'Programing' 카테고리의 다른 글
VB.NET IntelliSense : ENTER 자동 완성시 줄 바꿈 비활성화 (0) | 2020.07.13 |
---|---|
C ++에서 "const"는 몇 개나 어떤 것입니까? (0) | 2020.07.13 |
스파르타입니까? (0) | 2020.07.13 |
암호화 / 암호 보호 기능이있는 SQLite (0) | 2020.07.13 |
실행시에만 알려진 형식 인수로 일반 메서드 호출 (0) | 2020.07.13 |