一个C#总结注释中的Xml字符串 [英] Xml string in a C# summary comment

查看:116
本文介绍了一个C#总结注释中的Xml字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在记录我在C#中编写的一些处理解析令牌的方法。由于系统其他领域的某些技术限制,这些令牌需要采取XML元素(即<$​​ c $ c>< tokenName /> )的形式。我想将这些令牌的格式放在总结语句中。



但是,这会抛出一个错误:格式错误的XML - 一个名称以无效字符开头。有没有任何可以使用的转义字符序列来嵌入我的C#总结评论中的XML?

解决方案

使用标准XML转义,例如:

 < summary>这需要& lt; token1& gt,并将其变成& lt; token2& gt;< ; / summary> 

键入或读取代码并不容易,但IntelliSense正确解除了您在工具提示中看到正确的,可读的东西。


I'm documenting a few methods I wrote in C# that deal with parsing tokens. Due to some technical restraints in other areas of the system, these tokens need to take the form of XML elements (i.e., <tokenName />). I'd like to put the format of those tokens in the summary statement itself.

However, this throws an error: Badly formed XML -- A name was started with an invalid character". Is there any sort of escape character sequence I can use to embed XML in my C# summary comments?

解决方案

Use standard XML escaping. For example:

<summary>This takes a &lt;token1&gt; and turns it into a &lt;token2&gt;</summary>

It's not super-easy to type or read as code, but IntelliSense properly unescapes this and you see the right, readable thing in the tooltip.

这篇关于一个C#总结注释中的Xml字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆