C# 2.0 Structs

Structs are lightweight types that make fewer demands on the operating system and on memory than conventional classes. PowerDesigner models C# 2.0 structs as classes with a stereotype of <<Structure>>.

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

A struct can implement interfaces but does not support inheritance; it can contain events, variables, constants, methods, constructors, and properties.

In the following example, the struct contains two attributes:



{
 public struct Point
 {
  public int New()
  {
   return 0;
  }
  private int x;
  private int y;
 }
}

Creating a Struct

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

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

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

Struct Properties

Struct 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 struct declaration.

Unsafe

Specifies the unsafe modifier for the struct declaration.