Question

In C# xml comments, what is the difference between the tags below?

1. <c> 
2. <code>
Was it helpful?

Solution

Assuming you are talking about tags in xml comments, c is like back-ticks in StackOverflow, while code is more like code blocks.

/// <summary>
/// This is the <c>SomeMethod</c> method of the <c>Program</c> class.
/// </summary>
/// <param name="s">A string.</param>
/// <example>
/// You can use this method like this:
/// <code>
/// string x = SomeMethod("foobar");
/// Console.WriteLine(x);
/// </code>
/// </example>
static string SomeMethod(string s){
    throw new NotImplementedException();
} 

OTHER TIPS

<c>Your code sample.</c>    

Indicates a short segment of code. You will use the c tag to draw attention to particular words, phrases or code in the resulting documentation. You will nest c tags within other tags.

<code>Your code sample.</code>  

The code tag is similar to the tag, but it is intended to illustrate a true code usage example. The code tag is generally enclosed within an tag set (see below).

If you mean in code comments, then <code> (generally used within <example>) represents multiple lines of illustrative code, where-as <c> represents just a single term to be written in a code font.

To use stackoverflow/markdown as a comparison, they are exactly the same as inline code in the middle of a paragrah, vs

a multi-line
code sample that
appears formatted separately
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top