CodeTypeDelegate Class
Represents a delegate declaration.
Assembly: System (in System.dll)
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. Dim delegate1 As New CodeTypeDelegate("TestDelegate") delegate1.Parameters.Add(New CodeParameterDeclarationExpression("System.Object", "sender")) delegate1.Parameters.Add(New CodeParameterDeclarationExpression("System.EventArgs", "e")) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Public Delegate Sub TestDelegate(ByVal sender As Object, ByVal e As System.EventArgs) ' End Class
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeTypeDeclaration
System.CodeDom.CodeTypeDelegate
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: