自动生成在Visual Studio 2010中的try catch块 [英] Auto-generate a try catch block in visual studio 2010

查看:542
本文介绍了自动生成在Visual Studio 2010中的try catch块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道,如果有一个键盘快捷方式或选择自动生成围绕在Visual Studio 2010语句的try / catch块?我可以看到,如果我看的覆盖文件,当我将鼠标悬停在一份声明中抛出什么异常。我想右击 - >生成的try / catch,因为这将节省大量的时间处理所有可能的情况。



这可能吗?


解决方案

使用鼠标




  1. 标记您的代码


  2. 右键单击


  3. 选择环绕与...


  4. 双击尝试




使用键盘#1




  1. 使用标记代码<大骨节病>移
    <大骨节病>控制 + <大骨节病> A ,或任何你的作品


  2. 菜单键 / 应用程序键 (或者<大骨节病>移 + <大骨节病> F10


  3. 键入<大骨节病>取值


  4. 键入<大骨节病> T


  5. 按<大骨节病>输入或<大骨节病>标签




使用键盘#2的(如 perlox 并的弗雷德里克诺林指出)




  1. 使用标记代码<大骨节病>移
    <大骨节病>控制 + <大骨节病> A ,或任何你


  2. 工作
  3. 按<大骨节病>控制 + <大骨节病> K ,后跟<大骨节病> CTRL + <大骨节病>取值


  4. 键入<大骨节病> T


  5. 按<大骨节病>输入或<大骨节病>标签



Anyone know if there is a keystroke shortcut or option to autogenerate a try/catch block around a statement in Visual Studio 2010? I can see what exceptions are thrown if I look at the overlay documentation when I hover over a statement. I'd like to right click -> generate try/catch, as it would save a lot of time in handling all possible cases.

Is this possible?

解决方案

Using the mouse

  1. Mark your code

  2. Right-click

  3. Select Surround with...

  4. Double-click try

Using the keyboard #1

  1. Mark your code using Shift, Ctrl + A, or whatever works for you

  2. Press Menu key / Application key (alternatively Shift + F10)

  3. Type S

  4. Type T

  5. Press Enter or Tab

Using the keyboard #2 (as perlox and Fredrik Norlin points out)

  1. Mark your code using Shift, Ctrl + A, or whatever works for you

  2. Press Ctrl + K, followed by CTRL + S

  3. Type T

  4. Press Enter or Tab

这篇关于自动生成在Visual Studio 2010中的try catch块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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