Sometimes I just want to quickly run or test out a snippet of C# code.
Over the years, I’ve done that a few different ways:
- a project in Visual Studio that I use solely for the purpose of playing with small pieces of code
- C# interactive
Today I’m going to talk about using C# Interactive inside Visual Studio or by running csi.
Inside Visual Studio with or without a project open, go to View > Other Windows > C# Interactive.
Terminate each block of code with a
The easiest way to run it from the command prompt is to use the Developer Command Prompt for VS 2019 or whatever version of Visual Studio you are using.
csi to start C# interactive.
To exit csi type
It is also possible to put code in script files (.csx) and run them.