Click or drag to resize
RecurrenceRuleTryParse Method (String, RecurrenceRule)
Creates a recurrence rule instance from it's string representation.

Namespace: Kettic.AspNet.Controls
Assembly: Kettic.AspNet.Controls (in Kettic.AspNet.Controls.dll) Version: 2014.4.1129.0 (2014.04.1129.0)
Syntax
public static bool TryParse(
	string input,
	out RecurrenceRule rrule
)

Parameters

input
Type: SystemString
The string representation to parse.
rrule
Type: Kettic.AspNet.ControlsRecurrenceRule
When this method returns, contains the recurrence rule instance, if the conversion succeeded, or null if the conversion failed. The conversion fails if the value parameter is a null reference (Nothing in Visual Basic) or represents invalid recurrence rule.

Return Value

Type: Boolean
True if input was converted successfully, false otherwise.
Examples
using System;
using Kettic.AspNet.Controls;

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

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

            // Creates a recurrence rule to repeat the appointment every 2 hours.
            HourlyRecurrenceRule rrule = new HourlyRecurrenceRule(2, range);

            // Prints the string representation of the recurrence rule:
            string rruleAsString = rrule.ToString();
            Console.WriteLine("Recurrence rule:\n\n{0}\n", rruleAsString);

            // The string representation can be stored in a database, etc.
            // ...

            // Then it can be reconstructed using TryParse method:
            RecurrenceRule parsedRule;
            RecurrenceRule.TryParse(rruleAsString, out parsedRule);
            Console.WriteLine("After parsing (should be the same):\n\n{0}", parsedRule);
        }
    }
}

/*
This example produces the following results:

Recurrence rule:

DTSTART:20070601T123000Z
DTEND:20070601T130000Z
RRULE:FREQ=HOURLY;COUNT=10;INTERVAL=2;


After parsing (should be the same):

DTSTART:20070601T123000Z
DTEND:20070601T130000Z
RRULE:FREQ=HOURLY;COUNT=10;INTERVAL=2;*/
See Also