您的位置:首页 > 编程语言 > C#

C# 委托

2015-09-08 11:26 525 查看
public delegate int ceshi(int a, int b);
static int ax(int a, int b) {
return a * b;
}
static int bx(int a, int b) {
return a / b;
}
static void Main(string[] args)
{
ceshi wo;
Console.WriteLine("请输入数");
string c = Console.ReadLine();
int d = c.IndexOf(" ");
if (d > 0)
{
int a = Convert.ToInt32(c.Substring(0, d));
int b = Convert.ToInt32(c.Substring(d + 1));
Console.WriteLine("请输入M");
c = Console.ReadLine();
if (c.ToUpper() == "M")

wo = ax;

else
wo = bx;

Console.WriteLine(wo(a, b));
Console.ReadKey();

}
else {
Console.WriteLine("出来");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: