#include <stdio.h>
void square(int x) { printf("square of %d is %d\n",x,x*x); }
void cube(int x) { printf("cube of %d is %d\n",x,x*x*x); }
int main()
{
void (*calcu)(int x);
calcu=square;
calcu();
return ;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Delegate
{
class Program
{
static void square(int x) { Console.WriteLine("square of {} is {}", x, x * x); }
static void cube(int x) { Console.WriteLine("cube of {} is {}", x, x * x * x); }
delegate void math(int x); //定义委托类型
static void Main(string[] args)
{
math calcu;
calcu += square;
calcu();
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Delegate
{
public delegate void math(int x);
public class Calcu
{
public math calcu;
}
class Program
{
static void square(int x) { Console.WriteLine("square of {} is {}", x, x * x); }
static void cube(int x) { Console.WriteLine("cube of {} is {}", x, x * x * x); }
static void Main(string[] args)
{
Calcu c = new Calcu();
c.calcu += square;
c.calcu += cube;
c.calcu();
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Delegate
{
public delegate void math(int x);
public class Calcu
{
public event math calcu;
public void calculate(int x)
{
calcu(x);
}
}
class Program
{
static void square(int x) { Console.WriteLine("square of {} is {}", x, x * x); }
static void cube(int x) { Console.WriteLine("cube of {} is {}", x, x * x * x); }
static void Main(string[] args)
{
Calcu c = new Calcu();
c.calcu += square;
c.calcu += cube;
c.calculate();
Console.ReadKey();
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有