New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Occurrences of this rule repeat on a yearly basis.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class YearlyRecurrenceRule : RecurrenceRule, ISerializable, IEquatable<RecurrenceRule>

Inheritance: objectRecurrenceRuleYearlyRecurrenceRule

Implements: IEquatable<RecurrenceRule>ISerializable

Inherited Members RecurrenceRule.rulePatternRecurrenceRule.ruleRangeRecurrenceRule.EmptyRecurrenceRule.FromPatternAndRange(RecurrencePattern, RecurrenceRange)RecurrenceRule.TryParse(string, out RecurrenceRule)RecurrenceRule.TryParse(string)RecurrenceRule.TryParse(string, string, out RecurrenceRule)RecurrenceRule.IsValidValue<T>(T, T, T)RecurrenceRule.ValidateValue<T>(string, T, T, T)RecurrenceRule.SetEffectiveRange(DateTime, DateTime)RecurrenceRule.ClearEffectiveRange()RecurrenceRule.ToString()RecurrenceRule.ToString(TimeZoneInfoProvider)RecurrenceRule.GetHashCode()RecurrenceRule.Equals(object)RecurrenceRule.Equals(RecurrenceRule)RecurrenceRule.MatchDayOfWeekMask(DateTime)RecurrenceRule.MatchDayOrdinal(DateTime)RecurrenceRule.GetObjectData(SerializationInfo, StreamingContext)RecurrenceRule.RangeRecurrenceRule.PatternRecurrenceRule.OccurrencesRecurrenceRule.HasOccurrencesRecurrenceRule.ExceptionsRecurrenceRule.HasExceptionsRecurrenceRule.MaximumCandidatesRecurrenceRule.EffectiveStartobject.Equals(object, object)object.ReferenceEquals(object, object)object.GetType()object.MemberwiseClone()...

Example:

csharp
using System;
using Telerik.Web.UI;

namespace RecurrenceExamples
{
    class YearlyRecurrenceRuleExample1
    {
        static void Main()
        {
            // Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
            Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
                Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");

            // Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
            RecurrenceRange range = new RecurrenceRange();
            range.Start = recurringAppointment.Start;
            range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
            range.MaxOccurrences = 5;

            // Creates a recurrence rule to repeat the appointment on the 1th of April each year.
            YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(RecurrenceMonth.April, 1, range);

            Console.WriteLine("Appointment occurrs at the following times: ");
            int ix = 0;
            foreach (DateTime occurrence in rrule.Occurrences)
            {
                ix = ix + 1;
                Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
            }
        }
    }
}

/*
This example produces the following results:

Appointment occurrs at the following times:
 1: 4/1/2007 10:00:00 AM
 2: 4/1/2008 10:00:00 AM
 3: 4/1/2009 10:00:00 AM
 4: 4/1/2010 10:00:00 AM
 5: 4/1/2011 10:00:00 AM
*/
csharp
Imports System
Imports Telerik.Web.UI

Namespace RecurrenceExamples
    Class YearlyRecurrenceRuleExample1
        Shared Sub Main()
            ' Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
            Dim recurringAppointment As New Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"), Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment")

            ' Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
            Dim range As New RecurrenceRange()
            range.Start = recurringAppointment.Start
            range.EventDuration = recurringAppointment.[End] - recurringAppointment.Start
            range.MaxOccurrences = 5

            ' Creates a recurrence rule to repeat the appointment on the 1th of April each year.
            Dim rrule As New YearlyRecurrenceRule(RecurrenceMonth.April, 1, range)

            Console.WriteLine("Appointment occurrs at the following times: ")
            Dim ix As Integer = 0
            For Each occurrence As DateTime In rrule.Occurrences
                ix = ix + 1
                Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime())
            Next
        End Sub
    End Class
End Namespace

'
'This example produces the following results:
'
'Appointment occurrs at the following times:
' 1: 4/1/2007 10:00:00 AM
' 2: 4/1/2008 10:00:00 AM
' 3: 4/1/2009 10:00:00 AM
' 4: 4/1/2010 10:00:00 AM
' 5: 4/1/2011 10:00:00 AM
'

Constructors

Initializes a new instance of the YearlyRecurrenceRule class.

C#
public YearlyRecurrenceRule(int dayOrdinal, RecurrenceMonth month, RecurrenceDay daysOfWeekMask, RecurrenceRange range, int interval)
Parameters:dayOrdinalint

The day ordinal modifier. See DayOrdinal for additional information.

monthRecurrenceMonth

The month in which the event recurs.

daysOfWeekMaskRecurrenceDay

A bit mask that specifies the week days on which the event recurs.

rangeRecurrenceRange

The RecurrenceRange instance that specifies the range of this rule.

intervalint

The interval (in years) between the occurrences.

Example:
cs-api-definition
using System;
using Telerik.Web.UI;

namespace RecurrenceExamples
{
class YearlyRecurrenceRuleExample4
{
static void Main()
{
// Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");

// Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
RecurrenceRange range = new RecurrenceRange();
range.Start = recurringAppointment.Start;
range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
range.MaxOccurrences = 5;

// Creates a recurrence rule to repeat the appointment on the second monday of April every other year.
YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(2, RecurrenceMonth.April, RecurrenceDay.Monday, range, 2);

Console.WriteLine("Appointment occurrs at the following times: ");
int ix = 0;
foreach (DateTime occurrence in rrule.Occurrences)
{
ix = ix + 1;
Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
}
}
}
}

/*
This example produces the following results:

Appointment occurrs at the following times:
1: 4/9/2007 10:00:00 AM
2: 4/13/2009 10:00:00 AM
3: 4/11/2011 10:00:00 AM
4: 4/8/2013 10:00:00 AM
5: 4/13/2015 10:00:00 AM
*/

Initializes a new instance of the YearlyRecurrenceRule class.

C#
public YearlyRecurrenceRule(int dayOrdinal, RecurrenceMonth month, RecurrenceDay daysOfWeekMask, RecurrenceRange range)
Parameters:dayOrdinalint

The day ordinal modifier. See DayOrdinal for additional information.

monthRecurrenceMonth

The month in which the event recurs.

daysOfWeekMaskRecurrenceDay

A bit mask that specifies the week days on which the event recurs.

rangeRecurrenceRange

The RecurrenceRange instance that specifies the range of this rule.

Example:
cs-api-definition
using System;
using Telerik.Web.UI;

namespace RecurrenceExamples
{
class YearlyRecurrenceRuleExample2
{
static void Main()
{
// Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");

// Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
RecurrenceRange range = new RecurrenceRange();
range.Start = recurringAppointment.Start;
range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
range.MaxOccurrences = 5;

// Creates a recurrence rule to repeat the appointment on the second monday of April each year.
YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(2, RecurrenceMonth.April, RecurrenceDay.Monday, range);

Console.WriteLine("Appointment occurrs at the following times: ");
int ix = 0;
foreach (DateTime occurrence in rrule.Occurrences)
{
ix = ix + 1;
Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
}
}
}
}

/*
This example produces the following results:

Appointment occurrs at the following times:
1: 4/9/2007 10:00:00 AM
2: 4/14/2008 10:00:00 AM
3: 4/13/2009 10:00:00 AM
4: 4/12/2010 10:00:00 AM
5: 4/11/2011 10:00:00 AM
*/

Initializes a new instance of the YearlyRecurrenceRule class.

C#
public YearlyRecurrenceRule(RecurrenceMonth month, int dayOfMonth, RecurrenceRange range, int interval)
Parameters:monthRecurrenceMonth

The month in which the event recurs.

dayOfMonthint

The day of month on which the event recurs.

rangeRecurrenceRange

The RecurrenceRange instance that specifies the range of this rule.

intervalint

The interval (in years) between the occurrences.

Example:
cs-api-definition
using System;
using Telerik.Web.UI;

namespace RecurrenceExamples
{
class YearlyRecurrenceRuleExample3
{
static void Main()
{
// Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");

// Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
RecurrenceRange range = new RecurrenceRange();
range.Start = recurringAppointment.Start;
range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
range.MaxOccurrences = 5;

// Creates a recurrence rule to repeat the appointment on the 1th of April every other year.
YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(RecurrenceMonth.April, 1, range, 2);

Console.WriteLine("Appointment occurrs at the following times: ");
int ix = 0;
foreach (DateTime occurrence in rrule.Occurrences)
{
ix = ix + 1;
Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
}
}
}
}

/*
This example produces the following results:

Appointment occurrs at the following times:
1: 4/1/2007 10:00:00 AM
2: 4/1/2009 10:00:00 AM
3: 4/1/2011 10:00:00 AM
4: 4/1/2013 10:00:00 AM
5: 4/1/2015 10:00:00 AM
*/

Initializes a new instance of the YearlyRecurrenceRule class.

C#
public YearlyRecurrenceRule(RecurrenceMonth month, int dayOfMonth, RecurrenceRange range)
Parameters:monthRecurrenceMonth

The month in which the event recurs.

dayOfMonthint

The day of month on which the event recurs.

rangeRecurrenceRange

The RecurrenceRange instance that specifies the range of this rule.

Example:
cs-api-definition
using System;
using Telerik.Web.UI;

namespace RecurrenceExamples
{
class YearlyRecurrenceRuleExample1
{
static void Main()
{
// Creates a sample appointment that starts at 4/1/2007 10:00 AM (local time) and lasts half an hour.
Appointment recurringAppointment = new Appointment("1", Convert.ToDateTime("4/1/2007 10:00 AM"),
Convert.ToDateTime("4/1/2007 10:30 AM"), "Sample appointment");

// Creates a recurrence range, that specifies a limit of 5 occurrences for the appointment.
RecurrenceRange range = new RecurrenceRange();
range.Start = recurringAppointment.Start;
range.EventDuration = recurringAppointment.End - recurringAppointment.Start;
range.MaxOccurrences = 5;

// Creates a recurrence rule to repeat the appointment on the 1th of April each year.
YearlyRecurrenceRule rrule = new YearlyRecurrenceRule(RecurrenceMonth.April, 1, range);

Console.WriteLine("Appointment occurrs at the following times: ");
int ix = 0;
foreach (DateTime occurrence in rrule.Occurrences)
{
ix = ix + 1;
Console.WriteLine("{0,2}: {1}", ix, occurrence.ToLocalTime());
}
}
}
}

/*
This example produces the following results:

Appointment occurrs at the following times:
1: 4/1/2007 10:00:00 AM
2: 4/1/2008 10:00:00 AM
3: 4/1/2009 10:00:00 AM
4: 4/1/2010 10:00:00 AM
5: 4/1/2011 10:00:00 AM
*/

Properties

Gets the day of month on which the event recurs.

C#
public int DayOfMonth { get; }
Property Value:

The day of month on which the event recurs.

Gets the day ordinal modifier. See DayOrdinal for additional information.

C#
public int DayOrdinal { get; }
Property Value:

The day ordinal modifier.

Gets the bit mask that specifies the week days on which the event recurs.

C#
public RecurrenceDay DaysOfWeekMask { get; }
Property Value:

A bit mask that specifies the week days on which the event recurs.

For additional information on how to create masks see the RecurrenceDay documentation.

Gets the interval (in years) between the occurrences.

C#
public int Interval { get; }
Property Value:

The interval (in years) between the occurrences.

Gets the month in which the event recurs.

C#
public RecurrenceMonth Month { get; }
Property Value:

The month in which the event recurs.

Methods

C#
protected override DateTime GetOccurrenceStart(int index)
Parameters:indexintReturns:

DateTime

Overrides: RecurrenceRule.GetOccurrenceStart(int)

C#
protected override bool MatchAdvancedPattern(DateTime start)
Parameters:startDateTimeReturns:

bool

Overrides: RecurrenceRule.MatchAdvancedPattern(DateTime)