Visual studio功能 - 注释代码Ctrl K - Ctrl C [英] Visual studio feature - commenting code Ctrl K - Ctrl C

查看:139
本文介绍了Visual studio功能 - 注释代码Ctrl K - Ctrl C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经评论过一段时间的回答之前关于visual studio如何使用 // / * * / 来注释代码。我正在考虑修改答案(包括我的发现),但我不得不先测试它,这是困惑我。

I commented on this answer some time ago regarding how visual studio comments out code with // or /* */. I was thinking to revise the answer (to include my findings) but I had to test it first, which kind of confused me.

我的发现是,按 Ctrl - K Ctrl - C 时,您将获得 / / * * /

My finding is that depending on what you comment when you press Ctrl - K, Ctrl - C you will get either // or /* */.

<start selection here>    code();
                          someCall();
                          thirdCall();<end selection here>

这将产生以下结果:

//code();
//someCall();
//thirdCall();



第二个例子:



Second example:

    <start selection here>code();
                          someCall();
                          thirdCall();<end selection here>

这将产生以下结果:

/*code();
someCall();
thirdCall();*/



第三个例子



Third example

    <start selection here>code();
                          //someCall();
                          thirdCall();<end selection here>

这将产生以下结果:

//code();
////someCall();
//thirdCall();

请注意,示例2和3是完全相同的选择,但是注释使Visual Studio 。

Note that example 2 and 3 is the exact same selection, but the comment makes Visual Studio interpret it differently.

为什么是这样?

推荐答案

是//用于完全由完整行组成的任何选择,以及/*...*/用于沿着一行开始/结束中间的任何内容。

The approach one would expect is to use // for any selection that is made up entirely of complete lines, and /*...*/ for anything that starts/ends mid-way along a line.

...这是它真正做的事。

...which is what it seems to actually do.

这篇关于Visual studio功能 - 注释代码Ctrl K - Ctrl C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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