Is Display the default property value in the class diagram supported ?

A Lamsal 1 Reputation point

Is it possible to display the default property value ( true in my case) in the class diagram? If yes how?

public class Test
public bool DefaultStatus {get;set;} = true;


Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,578 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 47,716 Reputation points

    AFAIK this is not supported. The problem is that there is no such thing as a default value for a property (which is what you're looking at). The compiler is playing tricks on you. When you use the syntax you're using the compiler silently generates a field behind the scenes and sets its default value. Because this is generated at compile time there is nothing in the class diagram to show.

    Even if you added a private field manually, it would show up in the diagram but not show the default value. To get the default value you need to use the Properties window (F4). For fields it shows the initial value which is the default value for the field. But, again, auto property fields won't show up here.

    0 comments No comments