我正在用 C# 编写 HTML 解析器,并希望在摘要 XML block 中包含它处理的 HTML 示例。如何防止 < 和 > 字符弄乱 Visual Studio 2008 的自动文档?
例子:
/// <summary>
/// Creates a FlowSegment based on an HTML code, i.e. <bold>
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public FlowSegment(string code)
{
不幸的是,该示例导致显示此构造函数的工具提示(部分):
XML comment includes invalid XML
而不是摘要评论。
如何转义 < 和 > 字符?
最佳答案
我找到的最佳解决方案是更改它,以便将 < 替换为 <
并将 > 替换为 >
在 XML specifications 中找到.
这使得示例看起来如下:
/// <summary>
/// Creates a FlowSegment based on an HTML code, i.e. <bold>
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public FlowSegment(string code)
{
这使得所需的工具提示正确显示。
关于c# - 如何在 C# 摘要中包含 html 标记,以便将其作为文本处理(而不是解析为 XML)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1083054/