01 Oct 2020
Do you ever wish you could just quickly run some C# code, without all the heavy lifting, like creating a new project, setting it up etc? Or worse yet, starting to experiment with some temporary code by modifying an existing solution, and then forgetting to remove your code, and lo and behold, the next thing you know it’s deployed to production?!
That would let you try different ways to solve problems, running code straight away, line by line, without having to restart your project and step into whichever function you’d be modifying instead.
If you’re on Windows, this is your lucky day (if you’re on macOS or Linux – don’t despair, read on, there’s a solution for you too). Both paid-for Visual Studio and free Visual Studio Community Edition have this awesome feature - C# Interactive.
To open C# Interactive panel, go to “View” -> “Other Windows” -> “C# Interactive”.
If you need to load additional assemblies (3rd party SDKs / libraries), you can use
and provide a full path to the assembly:
#help to see useful keyboard shortcuts that save you time when re-running and editing commands.
I have previously mentioned .NET Fiddle in the article on tools for .NET and Web development. It’s an awesome online REPL for C# (as well as F# and VB.NET). It’s the only online REPL that supports latest (at the time of writing) C# 8.0 features
Similar to C# Interactive in VS, it has syntax highlighting, code completion and loading of libraries – although the choice of is somewhat constrained to a pre-defined list.
If you are on macOS or Linux, but still want to use a local C# REPL, you can try
Although it doesn’t have all the standard features such as autocompletion and code highlighting, it
does the job just fine.
Also, you can use it as a script execution engine for your C# code – imagine writing your shell scripts in C# instead of bash/zsh/PowerShell!
It supports loading of NuGet packages in much better way than C# Interactive. Refer to the
Hopefully, this article helps you iterate faster and better when experimenting with C#, and cut down the time spent endlessly restarting your debugging sessions just when you need to change one line of code to try out something new.
Liked this article? Join my mailing list to get helpful advice, tips & reviews of dev tools for .NET development.