Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tag code in C# XML documentation

I have this function:

public static string Join(this IEnumerable<string> strings, string separator)
{
    return string.Join(separator, strings.ToArray());
}

which I want to document.
I want the <return> tag to say string.Join(separator, strings.ToArray()) since to anyone able to read C# code this says more than a thousand words. However, when I use

<return>string.Join(separator, strings.ToArray())</return>

then string.Join(separator, strings.ToArray()) will be formatted as plain text, which makes it almost unreadable. So I tried

<return><code>string.Join(separator, strings.ToArray())</code></return>

but this always creates a new paragraph...

So here's my question:
Is there a way to format a piece of text so that it appears as if it were code? I'd be satisfied with a fixed-width font.

like image 622
sbi Avatar asked Feb 23 '11 15:02

sbi


People also ask

What is a tag in C programming?

An optional identifier, called a "tag," gives the name of the structure type and can be used in subsequent references to the structure type. A variable of that structure type holds the entire sequence defined by that type. Structures in C are similar to the types known as "records" in other languages.

How do I start coding in C?

To start using C, you need two things: A text editor, like Notepad, to write C code. A compiler, like GCC, to translate the C code into a language that the computer will understand.


1 Answers

The <c> tag sounds like it's what you're looking for. Check out MSDN's tag reference for more details.

That said, are you sure you want the documentation to refer directly to the actions performed by the function? What if you decide to change the implementation later? I know this is a pretty trivial example, but food for thought! :)

like image 62
Jeremy Todd Avatar answered Sep 21 '22 10:09

Jeremy Todd