コード例 #1
0
        public Calendar UpdateCalendar(CalendarDay cDay)
        {
            Calendar tmpCal = (Calendar)this.Clone();

            tmpCal.calendarDays[cDay.day - 1] = cDay;
            return(tmpCal);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            CalendarDay[] cd = new CalendarDay[7];
            cd[0] = new CalendarDay(1, 1, "meeting");
            cd[1] = new CalendarDay(2, 1, "tests");
            cd[2] = new CalendarDay(3, 1, "review");

            Calendar baseCal = new Calendar(cd);

            System.Console.WriteLine("Original");
            baseCal.Print();

            Calendar personalCal = baseCal.UpdateCalendar(new CalendarDay(1, 1, "urgent flight"));

            System.Console.WriteLine("Updated = new (Immutable)");
            personalCal.Print();
            System.Console.WriteLine("Original is still alive");

            baseCal.Print();
            System.Console.Read();
        }