views:

514

answers:

5

Some programming language implementations provide a Read, Evaluate, Print Loop interactive shell to allow the programmer to evaluate expressions and program fragments, and to program in an incremental, interactive manner.

What implementations of a C# REPL have you used, and liked? It would be nice to have one that could integrate with Visual Studio as well.

I have found, but not tried, the Mono C# REPL and Don Box's C# REPL

+1  A: 

The best tool I've found for writing interactive c# code is the C# Snippet Compiler.

Not sure if it's exactly REPL but it is a great way to test out almost anything using C#/.NET.

It supports framework versions up to 3.5. It is not designed to integrate directly with Visual Studio, however it even provides its own intellisense.

Of course it's very easy to copy/export the code from this into your Visual Studio projects.

Ash
+2  A: 

Visual Studio 2008 includes REPL-like capabilities, though I wouldn't necessarily call them "good". I think they have the advantage of being included and always available--which can be handy when trying to do work at a workstation other than your own.

In Visual Studio, you can instantiate and invoke methods of objects using the Object Test Bench. You can also write interactive C# code (with many limits) using the Immediate Window (Debug->View->Immediate Window). Immediate Window can be used outside of a debugging session.

James Schek
A: 

I do not know of an interactive shell for running c# code snippets. There is one for the mono project, but I have not tried it: http://www.mono-project.com/CsharpRepl

I tried the C# snippet compiler, and it seems to be pretty much the same as creating a new console application in Visual Studio, but with limited intellisense, and none of the debugging features.

Right now I use the built in console application template anytime I want to try out simple input-output type experimental code. I use console Console.ReadLine() and Console.WriteLine() for input and output.

It actually works pretty well for me. I typically save all my little test programs so I can go back and find something I worked with a few months ago, and you get the full debugging features of Visual Studio.

Chris Mullins
+1  A: 

One that I've only seen is at the end of this video from PDC where Hejlsberg is going beyond C#4.

JP Alioto
Awesome video. The part about using the compiler as a service starts at 59 minutes and 25 seconds into the talk, but the entire video is great. Anders is a really smart guy, and he gives a really good talk.
Robert Harvey
+2  A: 

Mono comes with a REPL tool called "csharp". I just tried it on Mac OS X and it works like magic. The only feature it currently lacks is Intellisense, promised to appear in Mono 2.6

zvolkov