Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 251
Home
axunonb edited this page Jun 14, 2025
·
11 revisions

iCalendar is a widely used standard (RFC 5545) for exchanging calendar and scheduling information such as events, to-dos, journal entries, and free/busy information. It is supported by most major calendar applications and services, making it a common format for interoperability.
iCal.NET is a .NET library that provides a simple and flexible API for creating, parsing, and serializing iCalendar data. It is useful for:
- Generating
.icsfiles for calendar events and schedules. - Parsing existing iCalendar data from files or streams.
- Managing recurring events, time zones, and reminders.
- Integrating calendar functionality into .NET applications.
vardate=newCalDateTime(2024,10,15,11,0,0);varcalendarEvent=newCalendarEvent{// If Name property is used, it MUST be RFC 5545 compliantSummary="Event Title",// Should always be presentDescription="Event description goes here",// optionalStart=date,End=date.AddHours(2),};varcalendar=newIcal.Net.Calendar();calendar.Events.Add(calendarEvent);calendar.AddTimeZone(newVTimeZone("Europe/Copenhagen"));// TZ should be addedvarserializer=newCalendarSerializer();varserializedCalendar=serializer.SerializeToString(calendar);Console.WriteLine(serializedCalendar);Output (DTSTAMP and UID will differ):
BEGIN:VCALENDARPRODID:-//github.com/ical-org/ical.net//NONSGML ical.net 5.0.0//EN
VERSION:2.0
BEGIN:VEVENTDESCRIPTION:Event description goes here
DTEND:20241015T130000DTSTAMP:20241015T110000DTSTART:20241015T110000SEQUENCE:0
SUMMARY:Event Title
UID:a4982558-e1aa-412e-8610-e2102fe0e616
END:VEVENTBEGIN:VTIMEZONETZID:Europe/Copenhagen
X-LIC-LOCATION:Europe/Copenhagen
END:VTIMEZONEEND:VCALENDARvarnow=CalDateTime.Now;varlater=now.AddHours(1);// Repeat daily for 5 daysvarrrule=newRecurrencePattern(FrequencyType.Daily,1){Count=5};vare=newCalendarEvent{Start=now,End=later,RecurrenceRules=newList<RecurrencePattern>{rrule},};varcalendar=newCalendar();calendar.Events.Add(e);varserializer=newCalendarSerializer();varserializedCalendar=serializer.SerializeToString(calendar);Output:
BEGIN: VCALENDAR
VERSION:2.0
PRODID: -//github.com/ical-org/ical.net//NONSGML ical.net 5.0.0//EN
BEGIN:VEVENTDTEND:20160704T172520DTSTAMP:20160704T162520DTSTART:20160704T162520RRULE:FREQ=DAILY;COUNT=5SEQUENCE: 0
UID: f4693a88-0a57-4761-b949-8822b8a507d2
END:VEVENTEND:VCALENDAR