Export (0) Print
Expand All

UmAlQuraCalendar.GetDaysInYear Method (Int32, Int32)

Updated: October 2010

Calculates the number of days in the specified year of the specified era.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public override int GetDaysInYear(
	int year,
	int era
)

Parameters

year
Type: System.Int32
A year.
era
Type: System.Int32
An era. Specify UmAlQuraCalendar.Eras[UmAlQuraCalendar.CurrentEra].

Return Value

Type: System.Int32
The number of days in the specified year and era. The number of days is 354 in a common year or 355 in a leap year.

ExceptionCondition
ArgumentOutOfRangeException

year or era is outside the range supported by the UmAlQuraCalendar class.

The following example calls the GetDaysInYear method to get the number of days in ten consecutive years in each era supported by the UmAlQuraCalendar class.


using System;
using System.Globalization;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Calendar cal = new UmAlQuraCalendar();
      int currentYear = cal.GetYear(DateTime.Now);

      outputBlock.Text += "Era     Year     Days\n" + "\n";
      foreach (int era in cal.Eras)
      {
         for (int year = currentYear; year <= currentYear + 9; year++)
         {
            outputBlock.Text += String.Format("{0}{1}      {2}      {3}",
                              ShowCurrentEra(cal, era), era, year,
                              cal.GetDaysInYear(year, era)) + "\n";
         }
      }
      outputBlock.Text += "\n   * Indicates the current era." + "\n";
   }

   private static string ShowCurrentEra(Calendar cal, int era)
   {
      if (era == cal.Eras[Calendar.CurrentEra])
         return "*";
      else
         return " ";
   }
}
// The example displays the following output:
//       Era     Year     Days
//       
//       *1      1431      354
//       *1      1432      354
//       *1      1433      355
//       *1      1434      354
//       *1      1435      355
//       *1      1436      354
//       *1      1437      354
//       *1      1438      354
//       *1      1439      355
//       *1      1440      354
//       
//          * Indicates the current era.


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Date

History

Reason

October 2010

Corrected return value information and replaced the example.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft