CShell Brings a REPL to C#

| by Jeff Martin Follow 16 Followers on May 21, 2014. Estimated reading time: 1 minute |

The strength of C# as a statically typed language can also be a weakness when it comes to rapid prototyping and interactively exploring code.  Users of interpreted languages like Python and Clojure have long promoted the ability to use a REPL (Read, Evaluate, Print, Loop)—as a way to rapidly develop software.

Developers with a large investment in C# finding themselves with a desire to utilize REPL functionality without losing the C# language can use CShell created by Luke Buehler from Arnova Asset Management.  In a typical development session with C#, a programmer would have to open Visual Studio and create a new Console Application project.  At that point the code could be written and executed.  CShell simplifies this process, simply open up the CShell to immediately start working on the C# statements that you want to experiment with.

The CShell environment is based on a .CShell file.  It is written using regular C# and allows the user to define activities CShell should perform on startup and shutdown.  For example, the default settings call for the tutorial and a blank scratchpad to be opened.  When CShell is closed, the same file also dictates what actions to take, which in this case is asking for these files to be saved.

    public void OnOpened(Workspace workspace)    {

        workspace.Load(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true);




    public void OnClosing(Workspace workspace) {

        workspace.Save(workspace.CShellFileName + CShell.Constants.WorkspaceFileExtension, true);



The author notes is that the CShell environment, any loaded assemblies and evaluated code all share a common AppDomain, meaning that there is not any separation to protect the shell from errant code.  As this is a scripting environment, this is considered a feature not a bug.  CShell uses the Mono.Sharp compiler to compile and execute entered code in memory.

CShell is part of a broader field that includes scriptcs, LINQPad, and .NET Fiddle.  A Redditor also linked to the Mono project’s own REPL (which does include a functional GUI.)

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Already exists by Miodrag Milic

clojure by Dene Simpson

Clojure is a compiler. It is not interpreted

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you