I am trying to write documentation comments however I have a problem.
/// <summary>
/// Inserts an element into the System.Collections.Generic.List<T> at the specified
/// index.
/// </summary>
When I reach the <T>
Visual studio thinks I am trying to add another tag. what is the correct way to add comments like that (and if I could make them click able in the generated help text that would be a extra bonus)
The first rule for commenting is it should have /// three slash for comments as C# supports C++ style commenting so commenting can be done by // -- two slashes -- but for Documentation /// is necessary. We will go through each one by one. You can add a paragraph to the description by using <para> tag.
Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored by C# (will not be executed).
XML documentation comment is a special feature in C#. It starts with a triple slash /// and is used to categorically describe a piece of code.. This is done using XML tags within a comment. These comments are then, used to create a separate XML documentation file.
C# documentation comments are XML, so change your <
and >
to <
and >
.
What you're better off doing, though is, is using the <see>
tag to insert a hyperlink. In a <see>
tag, change <T>
to {T}
:
/// <summary>
/// Inserts an element into the <see cref="List{T}"/> at the specified
/// index.
/// </summary>
(Note that the cref
attribute is syntax-checked by the compiler, unlike ordinary text.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With