What is the purpose of documentation in C#?

October 1, 2026 3 answers
Asked by handwriting sample
I usually use // for comments, and I'm fine with writing detailed explanations when needed. Now that I'm working more with an existing C# codebase, I've started seeing ... blocks above classes and methods. What are they used for, and when should I choose them instead of regular // comments? I initially assumed they were related to HTML because of the XML-like syntax.

Answers

~six4supper
Theyโ€™re similar in spirit to Javadoc, JSDoc, Doxygen comments, and docstrings in other languages. In C#, typing /// immediately before a declaration usually makes the IDE generate a template with tags such as , , and . Theyโ€™re most valuable for public or widely used types and methods, particularly in a larger codebase.
Reply to this answer
+90DoorsOpen
is part of C# XML documentation comments. Visual Studio and other IDEs can read it and display the text in tooltips or IntelliSense when someone hovers over a class, method, or property. Regular // comments are mainly for developers reading the source, while XML documentation is especially useful for explaining a public API without requiring someone to inspect the methodโ€™s implementation.

handwriting sample: That clears it upโ€”thanks! I was seeing it in existing code and wasnโ€™t sure whether it was just a different comment style.

Reply to this answer
panorama.viewpoint
These comments can be emitted into an XML documentation file when documentation generation is enabled. Tools can then use that file to build API documentation, and the information can travel alongside a compiled DLL so other projects still get descriptions for methods and parameters. NuGet libraries commonly include this kind of documentation.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions