Example #1
0
        public void Show()
        {
            {
                //常规做法
                Student student = new Student()
                {
                    ID   = 123,
                    name = "hzq"
                };
                student.SayMorning("kc");
            }

            {
                //增加不同的人不同的打招呼的方式,才分成不同的方法,不同的对象执行不同的方法
                Student student = new Student()
                {
                    ID   = 123,
                    name = "hzq"
                };
                student.SayMorning("fq", Student.PeopleType.Chiness);

                student.SayMorning("cc", Student.PeopleType.America);
            }

            {
                Student student = new Student()
                {
                    ID   = 123,
                    name = "hzq"
                };
                SayMorningCallBack mathod = new SayMorningCallBack(student.SayMorning_Chiness);
                mathod.Invoke("hzq");

                SayMorningCallBack mathod2 = new SayMorningCallBack(student.SayMorning_America);
                mathod2.Invoke("cc");
            }
        }
Example #2
0
 public void SayMorningPrefect(string name, SayMorningCallBack mathod)
 {
     Console.WriteLine("写日志");
     mathod.Invoke(name);
     Console.WriteLine("后续操作");
 }