C# Script files is similar like other script files that contain a piece of C# code and can execute and returns the results. As I said it is only piece of code – you really don’t have to have like a class or method to get the result. The C# script file (CSX) file is it’s own container and execute like a method. For Visual Studio, you can execute the CSX Script either using C# Interactive Window or CSI Command Line Window.
Before your proceed further, you must read following two posts to understand more about the new C# Interactive Window and the Command Line Interactive script engine for Visual Studio.
- Use C# Interactive Window for your coding experiment in Visual Studio 2015
- Command Line C# Interactive Script Execution for Visual Studio
Consider you have following C# Script file named “MyScript.csx” which just print a series of number from a defined collection.
To run the script from the C# Interactive Window, write the following command and press enter.
You will have following output :;
Similarly from the Command Prompt, open the Visual Studio Command Prompt and run the following command.
Once the script loads and execute, you will have the following output.
Hope this helps !
Very nice article Abhijit. I’m really enjoying the series on Visual Studio 🙂
Thanks a lot mate. Glad to know.. Thanks for sharing them via your The Daily Six Pack series.. Have a great time !
Pingback: Visual Studio – Developer Top Ten for Jan 20th, 2016 - Dmitry Lyalin
Pingback: Using Command Window in Visual Studio
Pingback: Calling current project methods from C# Interactive Window in Visual Studio 2015 ?