sin*_*zzy 6 xml vb.net url comments ampersand
这可能是一件简单的事情,但在VB2010中,我喜欢将我的源代码放在例程注释中.有些URL嵌入了&符号,IDE会将其标记为警告.
''' <summary>
''' routine that creates a new file based on a definition query.
''' </summary>
''' <param name="newLoc"></param>
''' <returns></returns>
''' <remarks>
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=194920#580036
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=155005#452664
''' </remarks>
Public Function DoSelectLoc(ByVal newLoc As NewLocation) As Boolean
'my routine
End Function
Run Code Online (Sandbox Code Playgroud)
上面的两个URL标有警告.我已经尝试了几种替代方法来编写URL,但没有一种方法可行.我已经尝试了HTML代码,&但仍然有&符号.我知道IDE使用XML作为注释,但必须有一些方法来编写URL而不会收到警告并仍保持相同的引用链接.
更新:基于此处的讨论http://social.msdn.microsoft.com/Forums/en-US/f14e7b55-c352-4ca5-a82c-bca3b83818db/double-ampersand-in-a-code-comment-causes-intellisense -error我决定使用CDDATA来封装我的URL,如下所示:
''' <remarks>
''' <![CDATA[
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=194920#580036
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=155005#452664
''' ]]>
''' </remarks>
Run Code Online (Sandbox Code Playgroud)
似乎工作以允许链接正常工作,也不会使Visual Studio警告绊倒.
正确的XML语法是&ie
''' <remarks>
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=194920#580036
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=155005#452664
''' </remarks>
Run Code Online (Sandbox Code Playgroud)
根据此处的讨论,我决定使用CDATA来封装我的网址,如下所示:
''' <remarks>
''' <![CDATA[
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=194920#580036
''' http://forums.esri.com/Thread.asp?c=93&f=992&t=155005#452664
''' ]]>
''' </remarks>
Run Code Online (Sandbox Code Playgroud)
似乎可以正常工作,以允许链接正常工作,并且也不会触发Visual Studio警告。