Mega Code Archive

 
Categories / C# / Class Interface
 

Structs And Enums

using System; using System.Collections.Generic; using System.Text; struct Date {     public Date(int ccyy, Month mm, int dd) {         this.year = ccyy - 1900;         this.month = mm;         this.day = dd - 1;     }     public override string ToString() {         return this.month + " " + (this.day + 1) + " " + (this.year + 1900);     }     private int year;     private Month month;     private int day; } enum Month {     January, February, March, April,     May, June, July, August,     September, October, November, December } class Program {     static void Entrance() {         Month first = Month.December;         Console.WriteLine(first);         first++;         Console.WriteLine(first);         Date defaultDate = new Date();         Console.WriteLine(defaultDate);         Date halloween = new Date(2008, Month.October, 31);         Console.WriteLine(halloween);     }     static void Main() {         try {             Entrance();         } catch (Exception ex) {             Console.WriteLine(ex.Message);         }     } }