125

剃刀视图中服务器端注释的语法是什么?

我想评论这段代码:

/*
@helper NavItem() {

}
*/
4

4 回答 4

225
@* here is the code to comment *@
于 2010-11-11T19:32:51.917 回答
49

Both of the following work

@{
/*
    This is a comment
*/}


@//This is another comment

Update

With the new Beta of MVC 3 out the old methods of highlighting won't work.

@{
    //This is a comment
}

@{/*
      This is a multi
      line comment
*/}

@*
      This is a comment, as well
*@

Is the updated method @//This is a comment and @/* */ will no longer work.

于 2010-08-01T20:38:16.933 回答
9

在 .cshtml 文件中,只需按cntrl+kcntrl+c,您会看到 Visual Studio 自动添加注释。(或者,cntrl_kcntrl+u用于取消注释。)或者如果您想手动编写它, 只是继续

@* Your Code *@
于 2014-07-02T11:04:56.690 回答
1

如果它在您看来,您不能使用标准的 HTML<!-- ... //-->或 .NET 样式<%-- .. --%>吗?

于 2010-08-01T17:04:36.247 回答