What is the purpose of documentation in C#?
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
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
Reply to this answer
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.
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.