Quickly introduce using statements and try...catch blocks
Apart from being able to generate blocks of code with live templates, ReSharper also lets you surround existing code with additional statements, such as try...catch
or using
statements.
To show the surround menu, select the block of code and press Alt+Control+J. This will pop up a menu of available surround statements:
![ReSharper: Quickly introduce using statements and try...catch blocks ReSharper: Quickly introduce using statements and try...catch blocks](https://resources.jetbrains.com/help/img/dotnet/2023.1/swTryCatch2.png)
Now, you can start typing the template name. For example, to surround selection with using
, you can start typing us...
while the popup is open. ReSharper will generate the default code stub and allow you to provide values for template parameters:
![ReSharper: Quickly introduce using statements and try...catch blocks ReSharper: Quickly introduce using statements and try...catch blocks](https://resources.jetbrains.com/help/img/dotnet/2023.1/swTryCatch3.png)
Last modified: 08 March 2021