Class Diagrams in C#


I would like to share an easy way to understand Class Diagrams in C#. We will use Visual Studio 2012 to generate Class Diagrams and we have this feature in Visual Studio 2012 to generate Class Diagrams and then we will learn the procedure step by step.


1. Create a few classes as per the screen below.

Create few class

  • We have added the four classes Person, Student, Emp and Customer.
  • The point to be noted here is, the Person class is a general class and the ohter classes, Emp, Student and Customer, are specific classes. Furthermore we will use Person as the base class for the other classes as in the following document.

2. Right-click on the project to create a Class Diagram as per the screen below.

create Class diagram

3. The following will be the output:

output of class diagram

  • We have a star symbol for protected members.
  • We have the Lock symbol for Private members.

4. Now use inheritance as in the following:

Now use inheritance

5. Again right-click on the project to generate Class Diagrams.

Person is the base class so the following is the output.

generate new class diagrams 

6. We can rearrange these boxes in the proper manner. These boxes can be dragged and dropped.

proper manner

7. Now we will use Interface as in the following:

we will use Interface 

8. Diagram for Interface:

Diagram for Interface

9. Using Interface1 in classes:

  Interface1 in Classes

10. Now create a diagram as in Step 2.

create diagram as per step 2 

11. Right-click on the box to see its properties.

see its properties 

12. Right-click on the inheritance line to see the details.

inheritance line to see details


We have learned how to create a Class Diagram using Visual Studio 2012. 

Up Next
    Ebook Download
    View all
    View all