Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an interactive shell for programming quick C# code snippets?

Tags:

c#

.net

Is there an interactive shell for programming quick code snippets in C#/.NET? Sometimes I'm interested in trying out a quick block of .NET code without creating a whole console application (that I then have to delete when I'm done).

I understand that the Immediate Window sort of provides this functionality, but it seems like you have to have an application open and be debugging it for the Immediate Window to be of any use.

I was tinkering with Ruby a while back, and the Interactive Ruby Shell (irb) was an invaluable little tool for trying out little snippets of Ruby code. Lightweight and instantaneous. This kind of thing seems like a no-brainer to me. Does anything like it exist for C#/.NET?

like image 425
Michael Avatar asked Aug 29 '11 17:08

Michael


People also ask

Does C# have a shell?

The C# interactive shell is built on top of the Mono. CSharp library, a library that provides a C# compiler service that can be used to evaluate expressions and statements on the flight as well as creating toplevel types (classes, structures, enumerations).

What is C# Interactive?

C# Interactive is an advanced Read- Eval- Print- Loop (REPL) editor. We can use this window for code testing. This window gives us the flexibility of testing programs without compiling. Hence, C# interactive is better than any other alternatives like C# code editor, C# pad and Online C# compiler for executing.

Does C# have a REPL?

The C# REPL Command-Line Interface (CSI. EXE) As with learning C# itself, the best way to get started with learning the C# REPL interface is to run it and begin executing commands.


1 Answers

LINQPad is very neat for that:

LINQPad is more than a LINQ tool: it's an ergonomic C#/VB/F# scratchpad that instantly executes any expression, statement block or program with rich output formatting – the ultimate in dynamic development. Put an end to those hundreds of Visual Studio Console projects cluttering your source folder!

like image 97
driis Avatar answered Nov 08 '22 11:11

driis