Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News CShell Brings a REPL to C#

CShell Brings a REPL to C#


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


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.

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

Community comments

  • Already exists

    by Miodrag Milic,

    Your message is awaiting moderation. Thank you for participating in the discussion.

  • clojure

    by Dene Simpson,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Clojure is a compiler. It is not interpreted

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

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