Method

You design a C# method using an operation.

The following table summarizes the different methods supported in PowerDesigner:

C# method

PowerDesigner equivalent

Extern

Select the Extern check box in the C# tab of the operation property sheet

New

Select the New check box in the C# tab of the operation property sheet

Virtual

Select the Virtual check box in the C# tab of the operation property sheet

Override

Select the Override check box in the C# tab of the operation property sheet

Unsafe

Select the Unsafe check box in the C# tab of the operation property sheet

Explicit

Select the Explicit check box in the C# tab of the operation property sheet

Static

Select the Static check box in the General tab of the operation property sheet

Sealed

Select the Final check box in the General tab of the operation property sheet

Abstract

Select the Abstract check box in the General tab of the operation property sheet

New

When a class inherits from another class and contains methods with identical signature as in the parent class, the New check box is automatically selected to make the child method prevail over the parent method.

BaseInitializer and ThisInitializer for Constructors

The Base Initializer property in the C# tab of the operation property sheet is used to create an instance constructor initializer of the form base. It causes an instance constructor from the base class to be invoked.

The This Initializer property in the C# tab of the operation property sheet is also used to create an instance constructor initializer, it causes an instance constructor from the class itself to be invoked.

In the following example, class B inherits from class A. You define a Base Initializer extended attribute in class B constructor, this extended attribute will be used to initialize class A constructor:



internal class B : A
 {
  public B(int x, int y) : base(x + y, x - y)
  {}
 }

Method Parameters

You define C# method parameters using operation parameters.

You can define the following parameter modifiers in PowerDesigner:

C# modifier

PowerDesigner equivalent

[none]

Select In in the Parameter Type box on the parameter property sheet General tab

ref

Select In/Out in the Parameter Type box on the parameter property sheet General tab

out

Select Out in the Parameter Type box on the parameter property sheet General tab

...

Select the Variable Argument checkbox on the parameter property sheet General tab

Method Implementation

Class methods are implemented by the corresponding interface operations. To define the implementation of the methods of a class, you have to use the To be implemented button in the Operations tab of a class property sheet, then click the Implement button for each method to implement. The method is displayed with the <<Implement>> stereotype.