C# coding style: comments

后端 未结 10 1434
后悔当初
后悔当初 2021-01-17 15:59

Most C# style guides recommend against the /* ... */ commenting style, in favor of // or ///. Why is the former style to be avoided?

10条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-17 16:30

    One example that comes to mind is that it's possible to accidentally interrupt a /* style comment. For example

    /* This is the start of a comment that documents the 
       behavior of the +-*/ operators in our program
    */ 
    

    This code does not compile, while the // variant would. Also the /// represents a specific style of documentation to which external tools respond differently.

提交回复
热议问题