views:

79

answers:

3

One thing I really love about languages such as Python is that if you have a piece of code you'd like to try out, you can just open the interactive shell and do it in seconds.

Is there a Visual Studio add-in that does the same for C#?

Basically what I'm looking for is something that opens up a window or tab with a text editor (preferably with code completion, because VS does it so nicely) and a button that runs the code and displays the output. Extra points for convenience features such as displaying complex output in a user-friendly way (think Firebug's console.log), automatically referencing all the assemblies the current project references, etc.

I tried googling for a while, but either I fail at coming up with good keywords, or no-one has made an add-in like this. If there really is none, I'm considering making one myself.

+2  A: 

I don't know about an add-in for VS but anytime I want to try something quickly (and don't want to fire up VS and create a console app) I use Snippet Compiler. It gets the job done as far as quickly testing methods and what not. I usually use it for things like testing a regex or trying out random datetime formatters. You can add references to other assemblies and it does provide some degree of intellisense.

Matt Dearing
This looks very promising. I might even be able to semi-integrate this into VS by creating a macro that launches it with some parameters for references etc, if it supports it. Hold on while I give it a spin.
Matti Virkkunen
I guess this is the closest I can get without writing a whole VS add-in. Even though it's not exactly what I was looking for, it's pretty close, and I can always write that macro I thought about. Thanks!
Matti Virkkunen
+1  A: 

I have a test.vcproj project sitting around with a test.cpp file which I paste code into. It's the best I could come up with.

sbi
same here. Another method, somewhat quicker but less versatile is a commandline compile; I have a few bat files like 'compile_and_run.bat' taking a single file as argument.
stijn
+2  A: 

LinqPad will execute C# snippets as well as LINQ. Nice except that autocompletion is not included in the free version. Of course you can write statements in VS with autocompletion, then copy/paste them into Linqpad.

Joe