MulticastDelegate定义:
[Serializable]
public abstract class MulticastDelegate : Delegate
{
// Fields
private MulticastDelegate _prev;
// Methods
protected MulticastDelegate(object target, string method) : base(target, method)
{
}
protected MulticastDelegate(Type target, string method) : base(target, method)
{
}
。。。
Delegate的定义;
Serializable, ClassInterface(ClassInterfaceType.AutoDual)]
public abstract class Delegate : ICloneable, ISerializable
{
// Fields
private RuntimeMethodInfo _method;
private IntPtr _methodPtr;
private IntPtr _methodPtrAux;
private object _target;
// Methods
private Delegate()
{
this._method = null;
this._methodPtrAux = IntPtr.Zero;
}
protected Delegate(object target, string method)
{
this._method = null;
this._methodPtrAux = IntPtr.Zero;
if (target == null)
{
throw new ArgumentNullException("target");
}
if (method == null)
{
throw new ArgumentNullException("method");
}
this.InternalCreate(target, method, false);
}
protected Delegate(Type target, string method)
{
this._method = null;
this._methodPtrAux = IntPtr.Zero;
if (target == null)
{
throw new ArgumentNullException("target");
}
if (!(target is RuntimeType))
{
throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), "target");
}
if (method == null)
{
throw new ArgumentNullException("method");
}
this.InternalCreateStatic((RuntimeType) target, method);
}
。。。
但是:
public delegate void Feedback(System.Object value);
private void FeedbackToConsole(System.Object value)
{
Console.WriteLine("Processing {0}",value);
}
调用:
Set.ProcessingItem(
new Set.Feedback((new Program()).FeedbackToConsole)
);
问题是:Delegate和MulticastDelegate都没有单个参数的构造函数(单个参数会出异常),却可以正常执行,搞不懂啊?
.method public hidebysig specialname rtspecialname instance void .ctor(object 'object', native int 'method')runtimemanaged { }
运行时托管的,自动产生两个参数:object和method