What is XML documentation in C#?

What is XML documentation in C#?

C# xml comment tags

Although, at first glance, an XML document and an HTML document may seem very similar, there is a main difference and that is that HTML does not indicate what is being represented, it has ill-defined data with formatting elements, while XML contains self-defined data: it describes the content of what it tags.

Each XML document has a logical and a physical structure. The logical structure of the document is a series of declarations, elements, comments, etc. that are indicated in the document by explicit markup. The physical structure of the document is a series of units called entities, i.e. it indicates the data that the document will contain. The logical and physical structures must be nested correctly.

XML documents must have a hierarchical structure with respect to the tags that delimit their elements. This means that elements must be correctly nested and that elements cannot overlap each other. In addition, elements with content must be

Summary c# shortcut key

The xml:lang attribute describes the language contained by the a element, “Click for German”, while the hreflang attribute is a metadata, which in this case describes the language of some content external to this web page.

Content directly associated with the XML document (whether it is contained in the document directly or considers part of the document when it is processed or rendered) must use the xml:lang attribute to indicate the language of that content. Such an xml:lang attribute should be reserved for content authors to directly tag any natural language content they may have.

Read more  How do you write a good character letter for court?

When the language value is actually an attribute or metadata referring to some external content, xml:lang is not the appropriate choice. In these cases, it is necessary to store information about the language, but it does not refer to the content of the XML document (or included content, such as images, which are processed as part of the document) directly. In this case, an element or attribute must be defined using a different name, without using the xml:lang attribute. The value of the element or attribute must use BCP 47, just like xml:lang.


C# source files can have structured comments that generate API documentation for the types defined in those files. The C# compiler generates an XML file containing structured data representing the comments and API signatures. Other tools can process that XML output to create readable documentation in the form of web pages or PDF files, for example.

To create documentation for code, write special comment fields indicated by three forward slashes. Comment fields include XML elements that describe the block of code that follows the comments. For example:

The use of XML document comments requires delimiters that indicate where a documentation comment begins and ends. Use the following delimiters with XML documentation tags:

To reference XML elements (e.g., the function processes the particular XML elements you want to describe in an XML documentation comment), you can use the standard quotation mark mechanism (< and >). To refer to generic identifiers in code reference elements (cref), you can use escape characters (for example, cref=”List<T>”) or braces (cref=”List{T}”). As a special case, the compiler parses braces as angle brackets to make the creation of the documentation comment less complicated when referencing generic identifiers.

Read more  What is Tray workflow?

Documenting c# code

You can read about Sandcastle here by the way. “Sandcastle, created by Microsoft, is a free tool used to create MSDN-style documentation from .NET assemblies and their associated XML comment files. It is command-line based and has no graphical user interface, project management features or an automated system build process.” HTH!

There would be a point if Object Browser actually made<see/> website URIs clickable and recognized somehow (since Object Browser is not a tooltip). Just sayin’ ;-).

The team of editors writes about legal news and developments so that they are at your fingertips.