C# Interactive Window, inside Visual Studio, allows you to test code snippet without compiling the application. It supports several features like syntax highlighting, intellisense and more, and comes with a feature like 'Copy Code', that allows you to copy only the code part from that window.
In this quick blog post, we will discuss about the 'Copy Code' functionality part of the C# Interactive Window, inside Visual Studio.
Using C# Interactive Window, we can do a lot of things to execute our code without compiling the entire application. It allows you to see the output of your code by just entering it in the C# Interactive Window. You can even enter C# using directives inside the window to refer a particular namespace.
While you are writing too many lines of code, and executing the output for each entered block, its sometime difficult to copy each one of those blocks into the main code editor. Visual Studio provides a quick function to enable you to copy only the code portion, excluding the outputs.
To do this, select the block of lines (basically code and the output), right-click inside the window and click on the 'Copy Code' from the context menu entry. Alternatively, you can press 'CTRL + SHIFT + C' keyboard shortcut. Here's a screenshot of the same for your reference:
Once the code has been copied to the Clipboard, it will be available to paste in any editor window. Remember that, this feature copies only the code part.