前段时间我对this answer评论了visual studio如何使用//
或/* */
注释代码。我正在考虑修改答案(包括我的发现),但我必须首先测试它,这让我很困惑。
我的发现取决于当您按 Ctrl - K , Ctrl - C 时您评论的内容您将获得//
或/* */
。
<start selection here> code();
someCall();
thirdCall();<end selection here>
这将产生以下结果:
//code();
//someCall();
//thirdCall();
<start selection here>code();
someCall();
thirdCall();<end selection here>
这将产生以下结果:
/*code();
someCall();
thirdCall();*/
<start selection here>code();
//someCall();
thirdCall();<end selection here>
这将产生以下结果:
//code();
////someCall();
//thirdCall();
请注意,示例2和3的选择完全相同,但注释使Visual Studio以不同的方式对其进行解释。
为什么会这样?
答案 0 :(得分:2)
人们期望的方法是使用//用于完全由完整行组成的任何选择,并使用/*...*/用于任何开始/结束中途的任何选择一条线。
......这实际上就是这样。