本文整理匯總了C#中System.Globalization.CultureInfo.CurrentUICulture屬性的典型用法代碼示例。如果您正苦於以下問題:C# CultureInfo.CurrentUICulture屬性的具體用法?C# CultureInfo.CurrentUICulture怎麽用?C# CultureInfo.CurrentUICulture使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.CurrentUICulture屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Globalization;
using System.Threading;
public class Example
{
public static void Main()
{
// Display the name of the current thread 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);
}
}
輸出:
CurrentCulture is en-US. CurrentCulture is now th-TH. CurrentUICulture is en-US. CurrentUICulture is now ja-JP.
示例2: Main
//引入命名空間
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
[assembly:TargetFramework(".NETFramework,Version=v4.6")]
public class Example
{
public static async Task Main()
{
var tasks = new List<Task>();
Console.WriteLine("The current UI culture is {0}",
Thread.CurrentThread.CurrentUICulture.Name);
Thread.CurrentThread.CurrentUICulture = new CultureInfo("pt-BR");
// Change the current UI culture to Portuguese (Brazil).
Console.WriteLine("Current UI culture changed to {0}",
Thread.CurrentThread.CurrentUICulture.Name);
Console.WriteLine("Application thread is thread {0}",
Thread.CurrentThread.ManagedThreadId);
// Launch six tasks and display their current culture.
for (int ctr = 0; ctr <= 5; ctr++)
tasks.Add(Task.Run( () => {
Console.WriteLine("UI Culture of task {0} on thread {1} is {2}",
Task.CurrentId,
Thread.CurrentThread.ManagedThreadId,
Thread.CurrentThread.CurrentUICulture.Name);
} ));
await Task.WhenAll(tasks.ToArray());
}
}
輸出:
The current culture is en-US Current culture changed to pt-BR Application thread is thread 9 Culture of task 2 on thread 11 is pt-BR Culture of task 1 on thread 10 is pt-BR Culture of task 3 on thread 11 is pt-BR Culture of task 5 on thread 11 is pt-BR Culture of task 6 on thread 11 is pt-BR Culture of task 4 on thread 10 is pt-BR
示例3: Main
//引入命名空間
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
CultureInfo culture = CultureInfo.CurrentUICulture;
Console.WriteLine("The current UI culture is {0} [{1}]",
culture.NativeName, culture.Name);
}
}
輸出:
The current UI culture is English (United States) [en-US]
示例4: Main
//引入命名空間
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
Console.WriteLine("The current UI culture: {0}",
CultureInfo.CurrentUICulture.Name);
CultureInfo.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr-FR");
Console.WriteLine("The current UI culture: {0}",
CultureInfo.CurrentUICulture.Name);
}
}
輸出:
The current UI culture: en-US The current UI culture: fr-FR
示例5: Main
//引入命名空間
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Text;
using System.Threading;
using System.Globalization;
public class MainClass
{
public static void Main()
{
CultureInfo current = CultureInfo.CurrentCulture;
CultureInfo currentUI = CultureInfo.CurrentUICulture;
Console.WriteLine("CurrentCulture = {0}", current);
Console.WriteLine("CurrentUICulture = {0}", currentUI);
}
}