CodeTypeDelegate Class
Represents a delegate declaration.
System.CodeDom::CodeObject
System.CodeDom::CodeTypeMember
System.CodeDom::CodeTypeDeclaration
System.CodeDom::CodeTypeDelegate
Assembly: System (in System.dll)
The CodeTypeDelegate type exposes the following members.
| 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 a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | 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);
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
