tags:

views:

637

answers:

7

Sometimes it's handy to have access to your language to do quick things without starting Visual Studio and creating a new console app.

Is there something like Python's interactive mode or groovy shell, except for C#?

+12  A: 

Have a look at CsharpRepl (part of the Mono project). Never used it myself, I hasten to add.

For LINQ stuff, you should also look at LINQPad.

Jon Skeet
+1 for LinqPad, very handy
Binary Worrier
Indeed, LINQPad is useful for more than just LINQ!
Craig Stuntz
LinqPad is a great piece of software but i find Snippet Compiler to be the lightest and quickest for testing snippets. Give it a try as well.
Paul Sasik
I always run a VS Console App project in the background.
Mehrdad Afshari
CsharpRepl works quite well. Doesn't interpret files, but there was some development on it.
Dykam
+1 for LINQPad, I hadn't used that before. I don't have mono installed here, I'll have to check out CsharpRepl later tonight.
Seth
CSharpRepl *works*, but it's a little rough around the edges.
Seth
+1  A: 

Here is a Mono CsharpRepl which is what you are looking for.

This documents the features available in the C# interactive shell that is part of Mono's C# compiler. An interactive shell is usually referred to as a read eval print loop or repl. The C# interactive shell is built on top of the Mono.CSharp (http:/monodoc/N:Mono.CSharp) library, a library that provides a C# compiler service that can be used to evaluate expressions and statements on-the-fly.

David Basarab
+2  A: 

There are several.

Well, and the first couple of results are all about the same one ...
Joey
Looking at the first couple of results is usually not a good idea, no matter the search engine. You need to explore the first page or two, perhaps even three, if you are feeling ambitious. This, in addition to trying different search terms really helps broaden your search.
CSI doesn't seem to support the latestfeatures of the language. I found a tip here: http://www.codeproject.com/Messages/2635407/Update-for-NET-Framework-3-5.aspx that was supposed to fix this, but I was unable to get that version working properly.
Casebash
+4  A: 

Like others noted, Mono's CSharpRepl is probably the right answer. However, if you're not fixed to C#, then PowerShell is a pretty nice environment of playing around with .NET. I frequently use it to test regular expressions, format strings, etc. All the kinds of stuff you have ConsoleProject163 lying around for :)

Joey
+9  A: 

You can try Snippet Compiler

Giorgi
+1 thanks - I am pretty sure that this is what I was trying to find in my head when I asked the question.
Seth
You are welcome
Giorgi
Nice, for easy compilation, but not interactive
Casebash
+2  A: 

In addition to the other good answers here (+1), there is also CSI and the immediate window in Visual Studio.

Craig Stuntz
The immediate windows is nice, but you can't define classes on the fly.
Casebash
A: 

You can use this developed by Miguel De Icaza, is shipped with mono and have code completion

Kristian Damian