委托的自定义声明

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
public delegate double Cal(double a, double b);//在名称空间下声明委托
internal class Program
{
static void Main(string[] args)
{
Calcultor calcultor = new Calcultor();
Cal cal = new Cal(calcultor.Fun);
Console.WriteLine(cal(12.3, 12.777));
}
}
public class Calcultor
{
public double Fun(double x, double y)
{

return x * y;
}

}
}

posted @ 2025-07-04 15:00  C#菜鸟……  阅读(5)  评论(0)    收藏  举报