我们可以使用泛型使用多播委托吗?请用下面的代码解释它是如何可能的。
delegate string multidelegate<T1,T2>(T1 a,T2 b);
class mylogic
{
public void Method1(int a, int b)
{
Console.WriteLine("This is Method1 where value of multiplication is {0}",a*b);
}
public void Method2(double a, double b)
{
Console.WriteLine("This is Method2 where the value of multiplication is {0}",a*b);
}
}
class Program
{
static void Main(string[] args)
{
multidelegate<int,int> del = new multidelegate<int,int>(new mylogic().Method1).Tostring();
del += Convert.ToString(new multidelegate<double,double>(new mylogic().Method2).Tostring());
del(32,51);
}
}