GregorianCalendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) Method

Definition

Returns the week of the year that includes the date in the specified DateTime object.

[System.Runtime.InteropServices.ComVisible(false)]
public override int GetWeekOfYear(DateTime time, System.Globalization.CalendarWeekRule rule, DayOfWeek firstDayOfWeek);

Parameters

time
DateTime

The DateTime object to read.

rule
CalendarWeekRule

One of the CalendarWeekRule values that defines a calendar week.

firstDayOfWeek
DayOfWeek

One of the DayOfWeek values that represents the first day of the week.

Returns

A 1-based integer that represents the week of the year that includes the date in the time parameter.

Attributes

Exceptions

firstDayOfWeek is outside the range supported by the calendar.

-or-

rule is not a valid CalendarWeekRule value.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0