C# coding style: comments

后端 未结 10 1436
后悔当初
后悔当初 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:18

    I wouldn't say I have a strong view against either - but IMO the biggest issue is that /* and */ get messy if you have it nested, with the side effect that you can't copy/paste blocks around safely (quite).

    You can too-easily end up with the wrong code commented/enabled, or can end up with it not compiling because you've ended up with a /* /* */ */.

    If you copy a block of // around, no harm - just those lines remain commented.

提交回复
热议问题