本文整理汇总了C#中System.Globalization.HijriCalendar.GetDayOfYear方法的典型用法代码示例。如果您正苦于以下问题:C# HijriCalendar.GetDayOfYear方法的具体用法?C# HijriCalendar.GetDayOfYear怎么用?C# HijriCalendar.GetDayOfYear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了HijriCalendar.GetDayOfYear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Globalization;
public class SamplesHijriCalendar {
public static void Main() {
// Sets a DateTime to April 3, 2002 of the Gregorian calendar.
DateTime myDT = new DateTime( 2002, 4, 3, new GregorianCalendar() );
// Creates an instance of the HijriCalendar.
HijriCalendar myCal = new HijriCalendar();
// Displays the values of the DateTime.
Console.WriteLine( "April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar:" );
DisplayValues( myCal, myDT );
// Adds two years and ten months.
myDT = myCal.AddYears( myDT, 2 );
myDT = myCal.AddMonths( myDT, 10 );
// Displays the values of the DateTime.
Console.WriteLine( "After adding two years and ten months:" );
DisplayValues( myCal, myDT );
}
public static void DisplayValues( Calendar myCal, DateTime myDT ) {
Console.WriteLine( " Era: {0}", myCal.GetEra( myDT ) );
Console.WriteLine( " Year: {0}", myCal.GetYear( myDT ) );
Console.WriteLine( " Month: {0}", myCal.GetMonth( myDT ) );
Console.WriteLine( " DayOfYear: {0}", myCal.GetDayOfYear( myDT ) );
Console.WriteLine( " DayOfMonth: {0}", myCal.GetDayOfMonth( myDT ) );
Console.WriteLine( " DayOfWeek: {0}", myCal.GetDayOfWeek( myDT ) );
Console.WriteLine();
}
}
输出:
April 3, 2002 of the Gregorian calendar equals the following in the Hijri calendar: Era: 1 Year: 1423 Month: 1 DayOfYear: 21 DayOfMonth: 21 DayOfWeek: Wednesday After adding two years and ten months: Era: 1 Year: 1425 Month: 11 DayOfYear: 316 DayOfMonth: 21 DayOfWeek: Saturday