In this post, let us learn how to add Using directive automatically while pasting a line of code in Visual Studio. Visual Studio always brings improvements with developer productivity. No matter how small some of the features are, they always help improve developer productivity. One such part is Add missing using directives on paste. This feature automatically adds a directive when you paste a line of code. However, it’s turned off by default. You need to turn it on before you see it in action.
Add Using directive automatically on Paste
To turn on this feature, navigate to Tools > Options > Text Editor > C#. and select Add missing using directives on paste. Refer to the below image.
Related Tip: Using or Using ?
Once this is enabled, in the code editor, whenever you paste some line, which has reference assembly and the directives are not included, it will be automatically included.
Check this out in action.
Hope this helps.
Read : Exploring Azure DevOps APIs