/* This delegate can be used to reference any function that returns void and does not take any arguments */
        public static void Main()
        {
            Student student = new Student("Evan", 13, 8);

            /* The delegate declared above can be assigned as follows: */
            Del1 del = student.Birthday;
            /*  Invoke the delegate: */
            del();
            /*  Reassign the delegate: */
            del = student.Graduate;
            /*  Invoke the delgate again: */
            del();

            Console.WriteLine(student);
        }
Exemple #2
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();
        }
Exemple #3
0
 //studenti se sortiraju abecedno
 public static Comparison WhichStudentComesFirst(Student s1, Student s2)
 {
     return(String.Compare(s1.name, s2.name) < 0 ? Comparison.theFirstComesFirst : Comparison.theSecondComesFirst);
 }