System.MulticastDelegate Class

Assembly: Mscorlib.dll
Namespace: System
Summary
Represents a multicast delegate; that is, a delegate that can have more than one element in its invocation list.
C# Syntax:
[Serializable]
public abstract class MulticastDelegate : Delegate
Remarks
MulticastDelegate is a special class. Compilers and other tools can derive from this class, but you cannot derive from it explicitly. The same is true of the Delegate class.

A MulticastDelegate has a linked list of delegates, called an invocation list, consisting of one or more elements. When a multicast delegate is invoked, the delegates in the invocation list are called synchronously in the order in which they appear. If an error occurs during execution of the list then an exception is thrown.

See also:
System Namespace

System.MulticastDelegate Member List:

Public Properties
Method
(inherited from System.Delegate)
Read-only

See base class member description: System.Delegate.Method


Gets the static method represented by the delegate.
Target
(inherited from System.Delegate)
Read-only

See base class member description: System.Delegate.Target


Gets the class instance on which the current delegate invokes the instance method.
Public Methods
Clone
(inherited from System.Delegate)
See base class member description: System.Delegate.Clone


Creates a shallow copy of the delegate.
DynamicInvoke
(inherited from System.Delegate)
See base class member description: System.Delegate.DynamicInvoke


Dynamically invokes (late-bound) the method represented by the current delegate.
Equals Overridden:
Determines whether this multicast delegate and the specified object are equal.
GetHashCode Overridden:
Returns the hash code for this instance.
GetInvocationList Overridden:
Returns the invocation list of this multicast delegate, in invocation order.
GetObjectData Overridden:
Populates a SerializationInfo object with all the data needed to serialize this instance.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Public Operators and Type Conversions
op_Equality Determines whether two MulticastDelegate objects are equal.
op_Inequality Determines whether two MulticastDelegate objects are not equal.
Protected Constructors
ctor #1 Overloaded:
.ctor(object target, string method)

Initializes a new instance of the MulticastDelegate class.
ctor #2 Overloaded:
.ctor(Type target, string method)

Initializes a new instance of the MulticastDelegate class.
Protected Methods
CombineImpl Overridden:
Combines this Delegate with the specified Delegate to form a new delegate.
DynamicInvokeImpl Overridden:
Processes the full invocation list.
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
GetMethodImpl
(inherited from System.Delegate)
See base class member description: System.Delegate.GetMethodImpl


Gets the static method represented by the current delegate.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.
RemoveImpl Overridden:
Removes an element from the invocation list of this MulticastDelegate that is equal to the specified delegate.

Hierarchy:


System.MulticastDelegate Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the MulticastDelegate class.
C# Syntax:
protected MulticastDelegate(
   object target,
   string method
);
Parameters:

target

The object on which method is defined.

method

The name of the method for which a delegate is created.

Remarks
This MulticastDelegate.#ctor constructor is called from the class produced by the compiler-generated code.

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the MulticastDelegate class.
C# Syntax:
protected MulticastDelegate(
   Type target,
   string method
);
Parameters:

target

The type of object on which method is defined.

method

The name of the static method for which a delegate is created.

Remarks
This MulticastDelegate.#ctor constructor is called from a class to generate a delegate based on a static method name and the Type of the class that defines the method.

Return to top


Property: Method (read-only)
Inherited
See base class member description: System.Delegate.Method

Summary
Gets the static method represented by the delegate.
C# Syntax:
public MethodInfo Method {get;}
Exceptions
Exception Type Condition
MemberAccessException The caller does not have access to the method represented by the delegate (for example, if the method is private).
Remarks
This property applies only if the current delegate represents a static method.
See also:
MethodInfo | Delegate.GetMethodImpl

Return to top


Property: Target (read-only)
Inherited
See base class member description: System.Delegate.Target

Summary
Gets the class instance on which the current delegate invokes the instance method.
C# Syntax:
public object Target {get;}
Remarks
An instance method is a method that is associated with an instance of a class; a static method is a method that is associated with the class itself.

If the delegate invokes one or more instance methods, this property returns the target of the last instance method in the invocation list.

Return to top


Method: Clone()
Inherited
See base class member description: System.Delegate.Clone

Summary
Creates a shallow copy of the delegate.
C# Syntax:
public virtual object Clone();
Return Value:
A shallow copy of the delegate.
Implements:
ICloneable.Clone
Remarks
The clone has the same Type, target, method, and invocation list as the original delegate.

A shallow copy creates a new instance of the same type as the original object, and then copies the non-static fields of the original object. If the field is a value type, a bit-by-bit copy of the field is performed. If the field is a reference type, the reference is copied but the referred object is not; therefore, the reference in the original object and the reference in the clone point to the same object. In contrast, a deep copy of an object duplicates everything directly or indirectly referenced by the fields in the object.

Return to top


Overridden Method: CombineImpl(
   Delegate follow
)
Summary
Combines this Delegate with the specified Delegate to form a new delegate.
C# Syntax:
protected override Delegate CombineImpl(
   Delegate follow
);
Parameters:

follow

The delegate to combine with this delegate.

Return Value:
A Delegate that is the new root of the MulticastDelegate invocation list.

Return to top


Method: DynamicInvoke(
   object[] args
)
Inherited
See base class member description: System.Delegate.DynamicInvoke

Summary
Dynamically invokes (late-bound) the method represented by the current delegate.
C# Syntax:
public object DynamicInvoke(
   object[] args
);
Parameters:

args

An array of objects that are the arguments to pass to the method represented by the current delegate.

-or-

null, if the method represented by the current delegate does not require arguments.

An array of objects that are the arguments to pass to the method represented by the current delegate.

-or-

null, if the method represented by the current delegate does not require arguments.

Return Value:
The object returned by the method represented by the delegate.
Exceptions
Exception Type Condition
MemberAccessException The caller does not have access to the method represented by the delegate (for example, if the method is private).

-or-

The number, order, or type of parameters listed in args is invalid.

TargetException The method represented by the delegate is an instance method and the target object is null.

-or-

The method represented by the delegate is invoked on an object or a class that does not support it.

TargetInvocationException One of the encapsulated methods throws an exception.
Remarks
This method calls the Delegate.DynamicInvokeImpl method.
See also:
Delegate.DynamicInvokeImpl | Object

Return to top


Overridden Method: DynamicInvokeImpl(
   object[] args
)
Summary
Processes the full invocation list.
C# Syntax:
protected override object DynamicInvokeImpl(
   object[] args
);
Parameters:

args

The arguments to pass to the encapsulated method.

Return Value:
An array of type Object that contains the return value of the encapsulated method.
Exceptions
Exception Type Condition
MemberAccessException There is an attempt to invoke a method to which the caller does not have access (that is, a private method).
ArgumentException The number, order, or type of parameters is invalid.
TargetException An encapsulated method is not static, and the target object is null.

-or-

There is an attempt to invoke a method on an object or class that does not support the method.

TargetInvocationException One of the encapsulated methods throws an exception.

Return to top


Overridden Method: Equals(
   object obj
)
Summary
Determines whether this multicast delegate and the specified object are equal.
C# Syntax:
public override bool Equals(
   object obj
);
Parameters:

obj

The object to compare with this instance.

Return Value:
true if obj and this instance have the same invocation lists; otherwise, false.
Remarks
Two delegates are equal if they are not null and are of exactly the same type, their invocation lists contain the same number of elements, and every element in the invocation list of the first delegate is equal to the corresponding element in the invocation list of the second delegate.

Two invocation list elements are equal if they invoke the same instance method on the same target instance, or they invoke the same static method.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~MulticastDelegate();

For more information on members inherited from System.Object click on the link above.

Return to top


Overridden Method: GetHashCode()
Summary
Returns the hash code for this instance.
C# Syntax:
public override int GetHashCode();
Return Value:
A 32-bit signed integer hash code.

Return to top


Overridden Method: GetInvocationList()
Summary
Returns the invocation list of this multicast delegate, in invocation order.
C# Syntax:
public override Delegate[] GetInvocationList();
Return Value:
An array of delegates whose invocation lists collectively match the invocation list of this instance.
Remarks
The array contains a set of delegates, each with an invocation list of one entry. Invoking these delegates sequentially, in the order they appear in the array, produces the same results as invoking the current instance.

Return to top


Method: GetMethodImpl()
Inherited
See base class member description: System.Delegate.GetMethodImpl

Summary
Gets the static method represented by the current delegate.
C# Syntax:
protected virtual MethodInfo GetMethodImpl();
Return Value:
A MethodInfo describing the static method represented by the current delegate.
Exceptions
Exception Type Condition
MemberAccessException The caller does not have access to the method represented by the delegate (for example, if the method is private).
Remarks
This method applies only if the current delegate represents a static method.
See also:
MethodInfo | Delegate.Method

Return to top


Overridden Method: GetObjectData(
   SerializationInfo info,
   StreamingContext context
)
Summary
Populates a SerializationInfo object with all the data needed to serialize this instance.
C# Syntax:
public override void GetObjectData(
   SerializationInfo info,
   StreamingContext context
);
Parameters:

info

An object that holds all the data needed to serialize or deserialize this instance.

context

(Reserved) The location where serialized data is stored and retrieved.

Exceptions
Exception Type Condition
ArgumentNullException info is null.
Implements:
ISerializable.GetObjectData
Remarks
This method stores all the information in info necessary to serialize this instance.

The context parameter is reserved and is not currently used in the execution of this method.

See also:
Object | SerializationInfo

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: op_Equality(
   MulticastDelegate d1,
   MulticastDelegate d2
)
Summary
Determines whether two MulticastDelegate objects are equal.
C# Syntax:
public static bool operator ==(
   MulticastDelegate d1,
   MulticastDelegate d2
);
Parameters:

d1

The left operand.

d2

The right operand.

Return Value:
true if d1 and d2 have the same invocation lists; otherwise false.
Remarks
Two delegates are equal if they are not null and are of exactly the same type, their invocation lists contain the same number of elements, and every element in the invocation list of the first delegate is equal to the corresponding element in the invocation list of the second delegate.

Two invocation list elements are equal if they invoke the same instance method on the same target instance, or they invoke the same static method.

Return to top


Method: op_Inequality(
   MulticastDelegate d1,
   MulticastDelegate d2
)
Summary
Determines whether two MulticastDelegate objects are not equal.
C# Syntax:
public static bool operator !=(
   MulticastDelegate d1,
   MulticastDelegate d2
);
Parameters:

d1

The left operand.

d2

The right operand.

Return Value:
true if d1 and d2 do not have the same invocation lists; otherwise false.
Remarks
Two delegates are equal if they are not null and are of exactly the same type, their invocation lists contain the same number of elements, and every element in the invocation list of the first delegate is equal to the corresponding element in the invocation list of the second delegate.

Two invocation list elements are equal if they invoke the same instance method on the same target instance, or they invoke the same static method.

Return to top


Overridden Method: RemoveImpl(
   Delegate value
)
Summary
Removes an element from the invocation list of this MulticastDelegate that is equal to the specified delegate.
C# Syntax:
protected override Delegate RemoveImpl(
   Delegate value
);
Parameters:

value

The delegate to search for in the invocation list.

Return Value:
If value is found in the invocation list for this instance, then a new Delegate without value in its invocation list; otherwise, this instance with its original invocation list.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.