CodeTypeDelegate Class
Represents a delegate declaration.
Assembly: System (in System.dll)
System.CodeDom::CodeObject
System.CodeDom::CodeTypeMember
System.CodeDom::CodeTypeDeclaration
System.CodeDom::CodeTypeDelegate
| Name | Description | |
|---|---|---|
![]() | CodeTypeDelegate() | Initializes a new instance of the CodeTypeDelegate class. |
![]() | CodeTypeDelegate(String^) | Initializes a new instance of the CodeTypeDelegate class. |
| Name | Description | |
|---|---|---|
![]() | Attributes | Gets or sets the attributes of the member.(Inherited from CodeTypeMember.) |
![]() | BaseTypes | Gets the base types of the type.(Inherited from CodeTypeDeclaration.) |
![]() | Comments | Gets the collection of comments for the type member.(Inherited from CodeTypeMember.) |
![]() | CustomAttributes | Gets or sets the custom attributes of the member.(Inherited from CodeTypeMember.) |
![]() | EndDirectives | Gets the end directives for the member.(Inherited from CodeTypeMember.) |
![]() | IsClass | Gets or sets a value indicating whether the type is a class or reference type.(Inherited from CodeTypeDeclaration.) |
![]() | IsEnum | Gets or sets a value indicating whether the type is an enumeration.(Inherited from CodeTypeDeclaration.) |
![]() | IsInterface | Gets or sets a value indicating whether the type is an interface.(Inherited from CodeTypeDeclaration.) |
![]() | IsPartial | Gets or sets a value indicating whether the type declaration is complete or partial.(Inherited from CodeTypeDeclaration.) |
![]() | IsStruct | Gets or sets a value indicating whether the type is a value type (struct).(Inherited from CodeTypeDeclaration.) |
![]() | LinePragma | Gets or sets the line on which the type member statement occurs.(Inherited from CodeTypeMember.) |
![]() | Members | Gets the collection of class members for the represented type.(Inherited from CodeTypeDeclaration.) |
![]() | Name | Gets or sets the name of the member.(Inherited from CodeTypeMember.) |
![]() | Parameters | Gets the parameters of the delegate. |
![]() | ReturnType | Gets or sets the return type of the delegate. |
![]() | StartDirectives | Gets the start directives for the member.(Inherited from CodeTypeMember.) |
![]() | TypeAttributes | Gets or sets the attributes of the type.(Inherited from CodeTypeDeclaration.) |
![]() | TypeParameters | Gets the type parameters for the type declaration.(Inherited from CodeTypeDeclaration.) |
![]() | UserData | Gets the user-definable data for the current object.(Inherited from CodeObject.) |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() | PopulateBaseTypes | Occurs when the BaseTypes collection is accessed for the first time.(Inherited from CodeTypeDeclaration.) |
![]() | PopulateMembers | 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.
Note |
|---|
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 = gcnew CodeTypeDelegate( "TestDelegate" ); delegate1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); delegate1->Parameters->Add( gcnew 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);
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.




