如何在我的C#代码中使用不同口语的常量 [英] How to to use constants of different spoken languages in my C# code
本文介绍了如何在我的C#代码中使用不同口语的常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在C#代码中使用不同口语的常量。我必须为每种语言声明一个const,或者它已经在.Net中声明了?请帮帮我。
Hi,
I want to use constants of different spoken languages in my C# code. I have to declare a "const" for each language or it is already declared in .Net? Please help me out.
推荐答案
您可以使用.NET提供的CultureInfo对象的内置枚举。试试这个:
You can use the build-in Enumeration of CultureInfo objects that .NET provides. Try this:
// reference the the System.Globalization library
using System.Globalization;
//
// these libraries referenced only because I used Linq to get a List<CultureInfo>
//
using System.Collections.Generic;
using System.Linq;
//
private void ListAllCultures()
{
List<CultureInfo> culturesList =
CultureInfo.GetCultures(CultureTypes.AllCultures).ToList<CultureInfo>();
foreach(CultureInfo theCulture in culturesList)
{
Console.WriteLine
(
"Culture : {0} Language: {1}",
theCulture.Name,
theCulture.EnglishName
);
}
}
//
// in your code somewhere run this, then examine the Output Window contents
ListAllCultures();
在我的机器上,文化列表中有#378个条目。每个CultureInfo对象都有大量信息,包括日历信息等。
资源:[ ^ ],[ ^ ]
On my machine right now, the list of Cultures has #378 entries. There is a wealth of information in each CultureInfo object including Calendar information, etc.
Resources: [^], [^]
>
找到此链接
http://stackoverflow.com/questions/3217492/list-of-language-codes-in-yaml-or-json/3218922#3218922 [ ^ ]
这篇关于如何在我的C#代码中使用不同口语的常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文