Bagikan melalui


How to: Create Types by using Class Designer

Use Class Designer to visualize new types for Visual C# .NET and Visual Basic .NET projects on a class diagram. To see existing types on a class diagram, How to: View Existing Types (Class Designer).

  • Create a new type

  • Apply a custom attribute to a type

  • Apply a custom attribute to a type member

Create a new type

  1. In the Toolbox, under Class Designer, drag one of these onto a class diagram:

    • Class or Abstract Class

    • Enum

    • Interface

    • Structure (VB) or Struct (C#)

    • Delegate

    • Module (VB only)

  2. Name the type. Then select its access level.

  3. Select the file where you want to add the initial code for the type:

    • To create a new file and add it to the current project, select Create new file and name the file.

    • To add code to an existing file, select Add to existing file.

  4. Now add other items to define the type:

    For

    Add

    Classes, abstract classes, structures or structs

    Methods, properties, fields, events, constructors (method), destructors (method), and constants that define the type

    Enums

    Field values that make up the enumeration

    Interfaces

    Methods, properties, and events that make up the interface

    Delegate

    Parameters that define the delegate

    Module

    Methods, properties, fields, events, constructors (method), and constants that define the module

    See Creating Members.

Apply a custom attribute to a type

  1. Click the type's shape on a class diagram.

  2. In the Properties window, next to the Custom Attributes property for the type, click the ellipsis (…) button.

  3. Add one or more custom attributes with one per line. Don't enclose them in brackets.

    When you're done, the custom attributes are applied to the type.

Apply a custom attribute to a type member

  1. Click the member's name in its type's shape on a class diagram, or its row in the Class Details window.

  2. In the Properties window, find the member's Custom Attributes property.

  3. Add one or more custom attributes with one per line. Don't enclose them in brackets.

    When you're done, the custom attributes are applied to the type.

See Also

Tasks

How to: Define Inheritance Between Types (Class Designer)

How to: Define Associations Between Types (Class Designer)

Other Resources

Creating and Configuring Type Members (Class Designer)

Working with Class Diagrams (Class Designer)

Designing Classes and Types (Class Designer)