loading...

C# REPL

tallesl profile image Talles L ・1 min read

Having a quick C# REPL can help a lot on testing little snippets of code.

.NET Fiddle

The quickest one is probably .NET Fiddle, which can be accessed by your web browser and don’t required any setup or registering:

csi.exe

There’s a C# REPL in Visual Studio on View > Other Windows > C# Interactive:

Which opens:

You can also fire csi.exe directly outside of Visual Studio:

Having Visual Studio 2017 Enterprise and Visual Studio 2019 Community installed on my Windows machine, I’ve managed to find it on:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csi.exe

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Roslyn\csi.exe

dotnet-script

It seems that csi.exe is not available for folks using .NET Core on Linux yet. Fortunately, there’s dotnet-script:

$ dotnet tool install -g dotnet-script
You can invoke the tool using the following command: dotnet-script
Tool 'dotnet-script' (version '0.53.0') was successfully installed.
$ dotnet script
> Math.Pow(3, 2)
9

Other alternatives

I haven’t tested it myself, but a quick search gives LINQPad and CS-Script as alternatives.

Posted on by:

tallesl profile

Talles L

@tallesl

A Brazilian software developer 🇧🇷 that loves to play video-games 🎮, tries it best to be active on GitHub 💻, and sometimes writes here on DEV 📄.

Discussion

markdown guide