c# - 如何在 C# 摘要中包含 html 标记,以便将其作为文本处理(而不是解析为 XML)?

标签 c# xml visual-studio summary

我正在用 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. &lt;bold&gt;
  /// </summary>
  /// <param name="code"></param>
  /// <returns></returns>
  public FlowSegment(string code)
  {

这使得所需的工具提示正确显示。

关于c# - 如何在 C# 摘要中包含 html 标记,以便将其作为文本处理(而不是解析为 XML)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1083054/

相关文章:

c# - lambda 表达式的异常

c# - 使用 InteractionRequests 设计一个 "busy"对话框

android如何在右侧设置复选框图标?

java - JAXB 多行属性

visual-studio - 如何在 Visual Studio 2019 上使用 Bootstrap 5 和 Sass

c# - Action 和 ActionLink 不适用于 ASP.NET Mono Razor View

c# - 如何使用 .NET Framework 获取所有事件的 TCP 连接(无非托管 PE 导入!)?

c# - 使用 XElement 从自定义 XML 反序列化 `Dictionary<string, Tuple<string, List<string>>>`

visual-studio - VS2010 Console 应用添加引用问题

c++ - 返回 char*/Visual Studio 调试器异常