#759 – Creating a New Type from a Class Diagram

You can create new types by directly entering code in the editor window.  You can also add a new type from a class diagram.

To start with, either open an existing class diagram or create a new one.

To create a new type, right-click on an empty area in the class diagram and select Add and then Class.  Note that you can also create other types (e.g. Enum, Interface, or Struct).



The New Class dialog will appear and you can enter the name of the new class and select an access modifier.  Note that the filename will be based on the class name by default.



After you click OK, the new type will show up in the class diagram.



You can now open your new type in the code editor window, to see the code that was generated for you.




#756 – Viewing a Class Diagram in Visual Studio 2012

You can create and view a class diagram from within Visual Studio that shows all of the types in your project and their relationships.  This is helpful in understanding how your project is structured.

To create a class diagram that allows viewing all types in your project, do the following.

In Solution Explorer, right-click the project and select View Class Diagram.



A diagram will appear that shows all of the types in your project.  In this example, the diagram also shows that Terrier is a subclass of Dog and that the Dog class implements the IBark and IFetch interfaces.

You can also click on the double down arrow icon to expand any of the types.  (You may have to move them around to make things look pretty again).



You can also navigate to the code for any member shown in the diagram, by right-clicking on the member and selecting View Code.