C# 2.0 Delegates

Delegates are type-safe reference types that provide similar functions to pointers in other languages. PowerDesigner models delegates as classes with a stereotype of <<Delegate>> with a single operation code-named "<signature>". The visibility, name, comment, flags and attributes are specified on the class object whereas the return-type and parameters are specified on the operation.

A type-level (class or struct) delegate is modeled either as an operation bearing the <<Delegate>> stereotype, or as a namespace-level delegate in which the class representing the delegate is inner to the enclosing type.

For information about creating and working with classes, see Classes (OOM).



{
 public delegate int ActionOccurred();
}

Creating a Delegate

You can create a delegate in any of the following ways:
  • Use the Delegate tool in the C# 2.0 Toolbox.

  • Select Model > Delegate Objects to access the List of Delegate Objects, and click the Add a Row tool.

  • Right-click the model (or a package) in the Browser, and select New > Delegate.

Delegate Properties

Delegate property sheets contains all the standard class tabs along with the C# tab, the properties of which are listed below:

Property

Description

New

Specifies the new modifier for the delegate declaration.

Unsafe

Specifies the unsafe modifier for the delegate declaration.