Visual Studio 2019 注释语法

编程


如何在 Visual Studio 2019-VB.Net 中注释代码

我尝试过的:

这可能是一个愚蠢的问题,但我已经找到了答案..为了注释一行代码,我使用撇号代码’。 我见过示例代码使用斜杠代码/。 当我使用它时,我在使用 Visual Studio 2019 时遇到语法错误。哪种是发表评论的正确方法?
谢谢

解决方案1

要注释单行,请使用 ['] (撇号)。

其他选项是:
CTRL + K 然后 CTRL + C – 评论选定的行
CTRL + K 然后 CTRL + U – 取消注释所选行

解决方案2

补充一下 Maciej 所说的:对于 VB,’ 是注释指示符,但很少有语言使用它 – 许多语言使用 /* 或 // 来指示引用(对于 C# 中的 Intellisense / XML 注释,您使用三个: // /)

您可以在 VB 中使用三个引号执行相同的操作:”’
这允许您向方法、字段和属性添加文档,这些文档将由 Intellisense 拾取并在您开始使用它们时显示。

解决方案5

引用:

Visual Studio 2019 注释语法

注释的语法与IDE(Visual Studio)无关,而是与编程语言相关。
对于 VBA 或 VB.Net

VB
' This is a comment because of the ' at beginning.
A=1 ' and this is usually to comment the reason of the line of code
' so next is commented
' A=1

解决方案4

Thanks all for your replies. However, I have tried all your suggestions..CTRL + K then CTRL + U, one / , 2 //, etc....still getting syntax error. I've checked Options under TOOLS and nothing jumps out at me.

I guess I'll continue use the apostrophe. '

。 这只是让我烦恼:-)

コメント

タイトルとURLをコピーしました