【发布时间】:2011-03-31 15:57:21
【问题描述】:
在我的主类“A”中,我声明了一个函数并委托调用该函数,我想将我的委托传递给另一个类“B”,但 B 类如何知道委托的类型?
A级
public delegate void SendInfo(string[] info);
SendInfo sendInfo = new SendInfo(SendInformation); //I have a function SendInformation
B b = new B();
b.SetDelegate(sendInfo);
B类
public delegate void SendInfo(string[] info); //I know this is wrong but how will
SendInfo SendInformation; //this class know what SendInfo is?
public void SetDelegate(SendInfo sendinfo) //What type is this parameter?
{
sendinfo.GetType();
SendInformation = sendinfo;
}
谢谢,
埃蒙
【问题讨论】: