Visual Studio XML comments (summary) and special characters
I have a method in a C# / Wpf project and I'd like to co开发者_JS百科mment / document it using the XML comments like this
/// <summary>
/// Initialises Drag & Drop
/// </summary>
void initDragDrop()
{
}
When I now use this method somewhere in my project and hover the mouse over it, I get the message "XML comment contains invalid XML: At this place, no spaces are allowed" (I translated the text after the colon manually to english, so it may not be literally in your visual studio). I found out the problem is the "&" sign, if I remove it, it works fine. But I want to keep it, so how to I escape it in the XML summary? I tried "\&" but this isn't working.
Thanks for any hint!
Remember that the & character has special meaning in xml (the start of an entity). You need to write your comment like this instead (annoying, I know):
/// <summary>
/// Initialises Drag & Drop
/// </summary>
void initDragDrop()
{
}
I might be wrong on this next point, but I don't think you can even use a CDATA section to avoid the entity, because it breaks the comments. You must type out the entire &
entity.
精彩评论