Closing Brackets Visual Studio

痞子三分冷 提交于 2019-12-12 01:41:08

问题


I am working in Visual Studio 2008 in C# programming language. I am having a big problem in it, because when I am opening a bracket the Visual Studio is not automatically closing it as usual. I am having great difficulty on it in big methods which contains many brackets (if else/for).

Any help is very much appreciated!


回答1:


I suggest you install Productivity Power Tools or Resharper. Both these extensions have support for that.




回答2:


A good strategy is to type the brackets in pairs first:

public void foo()
{
}

Then add the content:

public void foo(List<int> values)
{
     foreach ()
     {
     }
}

There are keyboard shortcuts that allow you to do this faster. Try typing foreach then press Tab twice.

If you still manage to get confused it might be because your methods are too long. You can refactor your code into smaller methods. Use the "Extract Method" refactoring tool to help you do this.

You may also want to occasionally "Format Document". This will line up the braces for you, and indent your code. This will make it more obvious which braces match up.

You might also want to consider installing a third party extension such as Resharper.




回答3:


Have you tried the Productivity Power Tools? It looks like they added automatic brace completion in 10.0.10710.22.



来源:https://stackoverflow.com/questions/11640015/closing-brackets-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!