Question

During the last 10 minutes of Ander's talk The Future of C# he demonstrates a really cool C# Read-Eval-Print loop which would be a tremendous help in learning the language.

Several .NET4 related downloads are already available: Visual Studio 2010 and .NET Framework 4.0 CTP, Visual Studio 2010 and .NET Framework 4 Training Kit. Do you know what happened to this REPL? Is it somewhere hidden among examples?

I know about mono repl. Please, no alternative solutions.

Was it helpful?

Solution

The REPL demo was part of "what might happen next", i.e. after 4.0; in .NET 5.0 or something similar.

This is not 4.0 functionality, and never has been.

OTHER TIPS

It's probably worth mentioning that the Mono project already does have a C# REPL which i tend to use for those small checks you do now and then. Take a look. Also, if I'm testing an idea which I'm uncomfortable Mono is going to handle to well and it's not worth starting a new test project then Snippet Compiler always comes in handy.

The Immediate window (Debug>Windows>Immediate Ctrl+D, I ) is fairly good replacement that's built in. It does require you start the IDE and put a breakpoint on something.

It does give you the context of where you would like to do experimentation.

Marc's answer is entirely correct, the possibility of a repl or script like c# has been discussed by Eric Lippert in two blog posts:

I would add that, the 2010 CTP does contain an f# repl (not much use for c# but if you were interested in some aspect of the BCL or CLR then it might be sufficient for your needs)

I find that LINQPad makes up for the lack of a REPL in many cases. It would be nice to get it integrated into Visual studio so you could interact with your existing code base more easily though.

Take a look at this C# REPL Script Environment which is a great way to quickly run C# script (and learn how to code)

I just published a VisualStudio Extension that provides a REPL environment inside VisualStudio (namely a C# REPL Environment with a Fluent API for .NET and VisualStudio)

In addition to being able to write and execute quick C# snippets (in a REPL environment), you can program VisualStudio IDE in real time!

You can install it using VisualStudio's Extension Manager (search for C# REPL) or via the download link at the VisualStudio Gallery page: VisualStudio C# REPL

The VisualStudio C# REPL page also contains more details and code samples.

There is also an Reddit thread on this extension (which contains more code samples).

Let me know what you think of it

Command-line REPL

To play with the C# REPL outside of Visual Studio, open the Developer Command Prompt for VS2015 and type the command csi to begin your interactive session. Here is a list of arguments that can be passed to csi.

Note: csi stands for "CSharp Interactive"

You can also open an interactive window directly from Visual Studio by navigating to View > Other Windows > C# Interactive.

Check out the Roslyn Wiki on the C# Interactive Window.

I found http://kamimucode.com/Home.aspx/C-sharp-REPL/1 . Which seems to be pretty good and I believe also exposes an API to evaluate expressions dynamically

To update on this old question c# REPL is now available as part of Visual studio IDE (starting VS 2015 update 1).

Introducing the Visual Studio 'C# REPL'

From time to time I want to try out some .NET API instead of wondering about C# language syntax. (There are far more subtleties in API than in the language itself.) If you are only looking for REPL for .NET, good old PowerShell is always with you.

C#:

using System;
using System.Text;

Convert.ToBase64String(Encoding.UTF8.GetBytes("Overflow"));

PowerShell:

[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("Overflow"))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top