本文整理匯總了C#中System.Globalization.DateTimeFormatInfo.GetEra方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTimeFormatInfo.GetEra方法的具體用法?C# DateTimeFormatInfo.GetEra怎麽用?C# DateTimeFormatInfo.GetEra使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Globalization.DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.GetEra方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Globalization;
public class SamplesGregorianCalendar {
public static void Main() {
// Creates strings with punctuation and without.
String strADPunc = "A.D.";
String strADNoPunc = "AD";
String strCEPunc = "C.E.";
String strCENoPunc = "CE";
// Calls DTFI.GetEra for each culture that uses GregorianCalendar as the default calendar.
Console.WriteLine( " ----- AD ----- ----- CE -----" );
Console.WriteLine( "CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR" );
foreach ( CultureInfo myCI in CultureInfo.GetCultures( CultureTypes.SpecificCultures ) ) {
Console.Write( "{0,-12}", myCI );
Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strADPunc ), myCI.DateTimeFormat.GetEra( strADNoPunc ) );
Console.Write( "{0,-7}{1,-9}", myCI.DateTimeFormat.GetEra( strCEPunc ), myCI.DateTimeFormat.GetEra( strCENoPunc ) );
Console.Write( "{0}", myCI.Calendar );
Console.WriteLine();
}
}
}
輸出:
----- AD ----- ----- CE ----- CULTURE PUNC NO PUNC PUNC NO PUNC CALENDAR ar-SA -1 -1 -1 -1 System.Globalization.HijriCalendar ar-IQ 1 1 -1 -1 System.Globalization.GregorianCalendar ar-EG 1 1 -1 -1 System.Globalization.GregorianCalendar ar-LY 1 1 -1 -1 System.Globalization.GregorianCalendar ar-DZ 1 1 -1 -1 System.Globalization.GregorianCalendar ar-MA 1 1 -1 -1 System.Globalization.GregorianCalendar ar-TN 1 1 -1 -1 System.Globalization.GregorianCalendar ar-OM 1 1 -1 -1 System.Globalization.GregorianCalendar ar-YE 1 1 -1 -1 System.Globalization.GregorianCalendar ar-SY 1 1 -1 -1 System.Globalization.GregorianCalendar ar-JO 1 1 -1 -1 System.Globalization.GregorianCalendar ar-LB 1 1 -1 -1 System.Globalization.GregorianCalendar ar-KW 1 1 -1 -1 System.Globalization.GregorianCalendar ar-AE 1 1 -1 -1 System.Globalization.GregorianCalendar ar-BH 1 1 -1 -1 System.Globalization.GregorianCalendar ar-QA 1 1 -1 -1 System.Globalization.GregorianCalendar bg-BG 1 1 -1 -1 System.Globalization.GregorianCalendar ca-ES -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-TW -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-CN -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-HK -1 -1 -1 -1 System.Globalization.GregorianCalendar zh-SG 1 1 -1 -1 System.Globalization.GregorianCalendar zh-MO 1 1 -1 -1 System.Globalization.GregorianCalendar cs-CZ -1 -1 -1 -1 System.Globalization.GregorianCalendar da-DK 1 1 -1 -1 System.Globalization.GregorianCalendar