Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("What type is declared when delegate keyword is used?");
            Console.WriteLine(typeof(Learn).BaseType.ToString());

            Console.WriteLine();

            Student student = new Student();
            ProgrammingCourse course = new ProgrammingCourse();
            student.AttendToCourse(course);

            //After a long time student will call
            student.StartLearningBecauseExamIsTomorrow();

            Console.Read();
        }
Exemplo n.º 2
0
 public void AttendToCourse(ProgrammingCourse course)
 {
     /*Instead of just learning and calling: course.StudyFirstChapter()
      * every lazy student will postpone this job and will add it to "toStudyDelegate" */
     toStudyDelegate += course.StudyFirstChapter;
 }