System.Globalization.CultureInfo enGB 做什么
what does System.Globalization.CultureInfo enGB do
我是 asp.net
的新人,我想知道 System.Globalization.CultureInfo enGB
是做什么的
完整代码(System.Globalization.CultureInfo enGB = new System.Globalization.CultureInfo("en-GB");
)
根据 MSDN 定义:
CultureInfo provides information about a specific culture (called a
locale for unmanaged code development). The information includes the
names for the culture, the writing system, the calendar used, the sort
order of strings, and formatting for dates and numbers.
CultureInfo
在您创建可能会被来自不同国家/地区的用户访问的应用程序时使用。所以基本上,如果您将文化设置为英语 - 英国,所有货币金额、日期和排序顺序都将根据 en-GB 文化完成。
示例:
decimal amount = 12.99M;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
//The amount will be displayed in pounds - £12.99
string amountPounds = amount.ToString("C");
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
//The anount will be displayed in dollars - .99
string amountDollars = amount.ToString("C");
我是 asp.net
的新人,我想知道 System.Globalization.CultureInfo enGB
是做什么的
完整代码(System.Globalization.CultureInfo enGB = new System.Globalization.CultureInfo("en-GB");
)
根据 MSDN 定义:
CultureInfo provides information about a specific culture (called a locale for unmanaged code development). The information includes the names for the culture, the writing system, the calendar used, the sort order of strings, and formatting for dates and numbers.
CultureInfo
在您创建可能会被来自不同国家/地区的用户访问的应用程序时使用。所以基本上,如果您将文化设置为英语 - 英国,所有货币金额、日期和排序顺序都将根据 en-GB 文化完成。
示例:
decimal amount = 12.99M;
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-GB");
//The amount will be displayed in pounds - £12.99
string amountPounds = amount.ToString("C");
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
//The anount will be displayed in dollars - .99
string amountDollars = amount.ToString("C");