namespace point{class Program{public class greetings{public static void EnglishGreeting(){Console.WriteLine("Hello World!");}public static void SpanishGreeting(){Console.WriteLine("Ciao,mondo!");}public static void ItaliamGreeting(){Console.WriteLine("Hola,imundo!");}delegate void greetingdele();class hello{static void Main(string[] args){int iChoice = int.Parse (args[0]);greetingdele[] deletest ={new greetingdele (greetings.ItaliamGreeting),new greetingdele (greetings .EnglishGreeting),new greetingdele (greetings .SpanishGreeting)};deletest[iChoice -1]();}}}}}问题1:int.Parse(args[0])这句是什么意思?问题2:deletest[iChoice-1]()是怎么一一访问到委托数组的元素的?问题3:Main方法里的参数 string[] args 有什么用?
2 回答
哆啦的时光机
TA贡献1779条经验 获得超6个赞
greetingdele[] deletest =
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
可能要改成
greetingdele[] deletest =new greetingdele[]
{
new greetingdele (greetings.ItaliamGreeting),
new greetingdele (greetings .EnglishGreeting),
new greetingdele (greetings .SpanishGreeting)
};
- 2 回答
- 0 关注
- 209 浏览
添加回答
举报
0/150
提交
取消