题目内容
阅读程序,写出程序运行结果。using System;using System.Collections.Generic;public delegate void sayhellodelegate(string name);class Program{static void Main(string[] args){List pp = new List();pp.Add(new People { Name = "马大云", Country = "中国", sayfunction = Chinesenihao });pp.Add(new People { Name = "Bill Gat", Country = "USA", sayfunction = EnglishHello });pp.ForEach(p => Say(p));Console.ReadKey();}public static void Say(People p){p.sayfunction(p.Name);}public static void Chinesenihao(string name){Console.WriteLine("{0}:老表,吃饭没?",name);}public static void EnglishHello(string name){Console.WriteLine("{0}:hi,the weather is nice today.",name);}}public class People{public string Name { get; set; }public string Country { get; set; }public sayhellodelegate sayfunction { get; set; }}
查看答案
搜索结果不匹配?点我反馈
更多问题