當前位置: 首頁>>代碼示例>>C#>>正文


C# PersianCalendar構造函數代碼示例

本文整理匯總了C#中System.Globalization.PersianCalendar.PersianCalendar構造函數的典型用法代碼示例。如果您正苦於以下問題:C# PersianCalendar構造函數的具體用法?C# PersianCalendar怎麽用?C# PersianCalendar使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在System.Globalization.PersianCalendar的用法示例。


在下文中一共展示了PersianCalendar構造函數的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

//引入命名空間
using System;
using System.Globalization;
 
class Sample 
{
    public static void Main() 
    {
      PersianCalendar jc = new PersianCalendar();
      DateTime thisDate = DateTime.Now;
 
        //--------------------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------------------
      Console.WriteLine("\n........... Selected Properties .....................\n");
      Console.Write("Eras:");
      foreach (int era in jc.Eras)
      {
         Console.WriteLine(" era = {0}", era);
      }
        //--------------------------------------------------------------------------------
      Console.WriteLine("\nTwoDigitYearMax = {0}", jc.TwoDigitYearMax);
        //--------------------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------------------
      Console.WriteLine("\n............ Selected Methods .......................\n");
 
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDayOfYear: day = {0}", jc.GetDayOfYear(thisDate));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDaysInMonth: days = {0}", 
                        jc.GetDaysInMonth( thisDate.Year, thisDate.Month, 
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetDaysInYear: days = {0}", 
                        jc.GetDaysInYear(thisDate.Year, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("GetLeapMonth: leap month (if any) = {0}", 
                        jc.GetLeapMonth(thisDate.Year, PersianCalendar.PersianEra));
        //-------------------------------------------------------------
      Console.WriteLine("GetMonthsInYear: months in a year = {0}", 
                        jc.GetMonthsInYear(thisDate.Year, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapDay: This is a leap day = {0}", 
                        jc.IsLeapDay(thisDate.Year, thisDate.Month, thisDate.Day, 
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapMonth: This is a leap month = {0}", 
                        jc.IsLeapMonth(thisDate.Year, thisDate.Month, 
                        PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
      Console.WriteLine("IsLeapYear: 1370 is a leap year = {0}", 
                        jc.IsLeapYear(1370, PersianCalendar.PersianEra));
        //--------------------------------------------------------------------------------
 
        // Get the 4-digit year for a year whose last two digits are 99. The 4-digit year 
        // depends on the current value of the TwoDigitYearMax property.
 
      Console.WriteLine("ToFourDigitYear:");
      Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", 
                         jc.TwoDigitYearMax, jc.ToFourDigitYear(99));
      jc.TwoDigitYearMax = thisDate.Year;
      Console.WriteLine("  If TwoDigitYearMax = {0}, ToFourDigitYear(99) = {1}", 
                        jc.TwoDigitYearMax, jc.ToFourDigitYear(99));
    }
}
開發者ID:.NET開發者,項目名稱:System.Globalization,代碼行數:66,代碼來源:PersianCalendar

輸出:

........... Selected Properties .....................

Eras: era = 1

TwoDigitYearMax = 99

............ Selected Methods .......................

GetDayOfYear: day = 1
GetDaysInMonth: days = 31
GetDaysInYear: days = 365
GetLeapMonth: leap month (if any) = 0
GetMonthsInYear: months in a year = 12
IsLeapDay: This is a leap day = False
IsLeapMonth: This is a leap month = False
IsLeapYear: 1370 is a leap year = True
ToFourDigitYear:
If TwoDigitYearMax = 99, ToFourDigitYear(99) = 99
If TwoDigitYearMax = 2012, ToFourDigitYear(99) = 1999


注:本文中的System.Globalization.PersianCalendar.PersianCalendar構造函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。