C#编码风格:注释 [英] C# coding style: comments

查看:70
本文介绍了C#编码风格:注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数C#样式指南建议不要使用/* ... */注释样式,而建议使用//或///.为什么要避免使用前一种样式?

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

推荐答案

我不会说我反对其中任何一个-但IMO的最大问题是/* */如果嵌套的话会变得混乱,其副作用是您不能安全地(非常)复制/粘贴块.

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.

这篇关于C#编码风格:注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆