none
How can I draw nested classes with diagram in C#? RRS feed

  • Question

  • Hello,

    How can I draw nested classes with diagram in C#?

    I didn't see this option in visual studio.

    Thanks

    Wednesday, January 1, 2020 3:52 PM

Answers

  • There doesn't appear to be a way to create the nested class directly from the diagram.

    So I have resorted to working backwards. First I create a file with the nested class, even if it is empty of any members:

        public abstract class Employee
        {
            public class BenefitPackage
            {
            }
        }
    

    Then I add a class diagram to the project and I drag the top-level class from Class View into the diagram. This gives me the nested classes:

    Screenshot

    Once this is done, the members of either class can then be added into the diagram.

    • Marked as answer by Arash_89 Wednesday, January 1, 2020 4:27 PM
    Wednesday, January 1, 2020 4:10 PM
    Moderator

All replies

  • There doesn't appear to be a way to create the nested class directly from the diagram.

    So I have resorted to working backwards. First I create a file with the nested class, even if it is empty of any members:

        public abstract class Employee
        {
            public class BenefitPackage
            {
            }
        }
    

    Then I add a class diagram to the project and I drag the top-level class from Class View into the diagram. This gives me the nested classes:

    Screenshot

    Once this is done, the members of either class can then be added into the diagram.

    • Marked as answer by Arash_89 Wednesday, January 1, 2020 4:27 PM
    Wednesday, January 1, 2020 4:10 PM
    Moderator
  • Thank you, but why the VS team doesn't add this feature to VS?
    Wednesday, January 1, 2020 4:30 PM