using System; using System.Collections.Generic; using System.Linq; using System.Text; class DateExtensionTest { static void Main(string[] args) { DateTime date = new DateTime(2009, 3, 10); Console.WriteLine("The date is " + date.ToString()); date.DisplayDate(); //Console.WriteLine("The year is " + date.Year); } } static class DateExtensions { public static void DisplayDate(this DateTime date) { String[] months = { "Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" }; Console.WriteLine("The date is " + date.Day + " of " + months[date.Month - 1] + " " + date.Year); } public static int Year(this DateTime date) { return date.Year + 1; } }