本文整理汇总了C#中System.Resources.NeutralResourcesLanguageAttribute类的典型用法代码示例。如果您正苦于以下问题:C# NeutralResourcesLanguageAttribute类的具体用法?C# NeutralResourcesLanguageAttribute怎么用?C# NeutralResourcesLanguageAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NeutralResourcesLanguageAttribute类属于System.Resources命名空间,在下文中一共展示了NeutralResourcesLanguageAttribute类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Threading;
[assembly:NeutralResourcesLanguageAttribute("en")]
public class Example
{
public static void Main()
{
// Select the current culture randomly to test resource fallback.
string[] cultures = { "de-DE", "en-us", "fr-FR" };
Random rnd = new Random();
int index = rnd.Next(0, cultures.Length);
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultures[index]);
Console.WriteLine("The current culture is {0}",
CultureInfo.CurrentUICulture.Name);
// Retrieve the resource.
ResourceManager rm = new ResourceManager("ExampleResources" ,
typeof(Example).Assembly);
string greeting = rm.GetString("Greeting");
Console.Write("Enter your name: ");
string name = Console.ReadLine();
Console.WriteLine("{0} {1}!", greeting, name);
}
}
示例2:
//引入命名空间
using System.Resources;
[assembly:NeutralResourcesLanguage("en-US")]
示例3:
//引入命名空间
using System.Resources;
[assembly:NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]