Structs And Enums : struct : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » struct »

 

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);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» struct