CodeTypeDelegate Class

 

Represents a delegate declaration.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

System.Object
  System.CodeDom.CodeObject
    System.CodeDom.CodeTypeMember
      System.CodeDom.CodeTypeDeclaration
        System.CodeDom.CodeTypeDelegate

[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeTypeDelegate : CodeTypeDeclaration

NameDescription
System_CAPS_pubmethodCodeTypeDelegate()

Initializes a new instance of the CodeTypeDelegate class.

System_CAPS_pubmethodCodeTypeDelegate(String)

Initializes a new instance of the CodeTypeDelegate class.

NameDescription
System_CAPS_pubpropertyAttributes

Gets or sets the attributes of the member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyBaseTypes

Gets the base types of the type.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyComments

Gets the collection of comments for the type member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyCustomAttributes

Gets or sets the custom attributes of the member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyEndDirectives

Gets the end directives for the member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyIsClass

Gets or sets a value indicating whether the type is a class or reference type.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyIsEnum

Gets or sets a value indicating whether the type is an enumeration.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyIsInterface

Gets or sets a value indicating whether the type is an interface.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyIsPartial

Gets or sets a value indicating whether the type declaration is complete or partial.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyIsStruct

Gets or sets a value indicating whether the type is a value type (struct).(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyLinePragma

Gets or sets the line on which the type member statement occurs.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyMembers

Gets the collection of class members for the represented type.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyName

Gets or sets the name of the member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyParameters

Gets the parameters of the delegate.

System_CAPS_pubpropertyReturnType

Gets or sets the return type of the delegate.

System_CAPS_pubpropertyStartDirectives

Gets the start directives for the member.(Inherited from CodeTypeMember.)

System_CAPS_pubpropertyTypeAttributes

Gets or sets the attributes of the type.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyTypeParameters

Gets the type parameters for the type declaration.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubpropertyUserData

Gets the user-definable data for the current object.(Inherited from CodeObject.)

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventPopulateBaseTypes

Occurs when the BaseTypes collection is accessed for the first time.(Inherited from CodeTypeDeclaration.)

System_CAPS_pubeventPopulateMembers

Occurs when the Members collection is accessed for the first time.(Inherited from CodeTypeDeclaration.)

CodeTypeDelegate can be used to declare a delegate type, or event handler. A delegate defines a method signature that can be used by calback methods or event handlers. Delegates can be declared at the namespace level or nested inside other types. Delegates cannot be nested inside other delegates.

The ReturnType property specifies the data type of the event handler returned by the delegate. The Parameters property contains the parameters for the delegate type.

CodeTypeDelegate should not be used for enumeration, interface, or type declaration. Instead, use CodeTypeDeclaration for those.

System_CAPS_noteNote

Not all languages support the declaration of delegates. Call the Supports method with the DeclareDelegates flag to determine if it is supported in a particular language.

The following example code demonstrates use of a CodeTypeDelegate to declare a new delegate type.

// Declares a delegate type called TestDelegate with an EventArgs parameter.
CodeTypeDelegate delegate1 = new CodeTypeDelegate("TestDelegate");            
delegate1.Parameters.Add( new CodeParameterDeclarationExpression("System.Object", "sender") );
delegate1.Parameters.Add( new CodeParameterDeclarationExpression("System.EventArgs", "e") );        

// A C# code generator produces the following source code for the preceeding example code:

//     public delegate void TestDelegate(object sender, System.EventArgs e);

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: