I realized today that I don’t know how to escape characters in comments for C#. I want to document a generic C# class, but I cannot write a proper example since I don’t know how to escape the < and > characters. Do I have to use < and >? I don’t like if that is the case since I want to make it easy to read the comment in the actual document so I don’t have to generate some kind of code document to be able to read the example code.
I realized today that I don’t know how to escape characters in comments for
Share
If you need to escape characters in XML comments, you need to use the character entities, so
<would need to be escaped as<, as in your question.The alternative to escaping is using
CDATAsections, to the same effect.As you noted, this would produce good looking documentation, but a horrible comment to read…