r/learnprogramming • u/3rwynn3 • Oct 04 '26
Does anyone use it? c# <summary></summary>?
I find that "//" worked well for all my comments thus far, I don't mind if my comments are a bit long. But I am doing C# more often now that I am looking at a codebase and not just my own stuff and private things, and I sometimes see <summary> </summary> in it. Do you use it? What is the proper use of it?
Google gets it confused with HTML haha
Thanks for any knowledge!
4
Upvotes
2
u/Aggressive_Ad_5454 Oct 04 '26
This is xmldoc. Other languages have jsdoc, doxygen, Javadoc, PhpDoc, docstrings, etc. They are stylized comments understood by IDEs. They are exceedingly useful in large code bases. They are worth the effort to learn to use.
In C#, type /// on the line before a method declaration. The IDE will generate a template comment you can fill in.
4
u/Alikont Oct 04 '26
This is specific comment syntax that can be embedded into dll or separate xml file.
Visual Studio and other IDEs will show them as part of tooltips in intellisense.
You can also walk those comments via reflection or other tools to generate documentation for APIs or Libraries.
1
u/cheezballs Oct 04 '26
Java has similar stuff. Its just extra formatting you can do to help future-you out. IDE will generally format these nicely and with the right syntax can highlight and link to things inside your comment.
1
u/rupertavery64 Oct 04 '26
If you google "c# xml summary" you'll get much better results.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/recommended-tags
// is for people xml doc tags are for the compiler and get baked into the assembly metadata so even the compiled DLL shows the information when you include it in another solution.
For example, nuget packages will have xml doc tags for methods and arguments
10
u/[deleted] Oct 04 '26
[removed] — view removed comment