Click here to Skip to main content
13,865,187 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


12 bookmarked
Posted 23 Apr 2014
Licenced CPOL

Prototyping with C#? Thanks, Roslyn!

, 23 Apr 2014
Rate this:
Please Sign up or sign in to vote.
Prototyping with C#? Thanks, Roslyn!

Long before Roslyn was a thing at this years’ BUILD developer conference, it was being used by a small group of Microsofties to create something pretty sweet.

This thing allowed you to write C# at the command line. So yeah, think Python, but with C#. Quick to get started, quick to work with, quick to execute. In this post, I’m going to introduce you to – and show off – ScriptCS.

First thing’s first. Let’s get it installed. To do this, I’ll direct you to my ol’ faithful Chocolatey to make this happen with extreme ease. If you haven’t installed Chocolatey yet, go ahead and do that – I’ll wait the usual 10 seconds. :)

Once you’ve got Chocolatey installed, getting ScriptCS is as easy as:

cinst scriptcs

and voila! Now you’re all set. If you paid attention to what Chocolatey output while it was doing the install, you’ll see why we have Roslyn to thank for this beauty of a tool:


If you visit the ScriptCS website, a lot of what they’ll show you is how to write ScriptCS files using your favorite text editor, then executing them at the command line. That’s all well and good but honestly I don’t see how that’s any different than firing up VS or VS Express, writing a CS file, and cracking it off right within the IDE.

What’s valuable to me is firing up a command prompt and writing C# to test something. That quick. I work on an SDK at work and sometimes I want to just quickly verify that the SDK is doing what I expect. To this end, let’s see how easy ScriptCS makes this.

Let’s do a simple Hello World application without running any application other than our Command Prompt.

  1. Win + R
  2. ‘cmd’
  3. scriptcs

Boom, you’re sitting in the ScriptCS C# interpreter. Code away!

Console.WriteLine("Hello, World!");

And profit.


How hot is that? The beauty of this is imagine you have written a DLL or some other reusable component and wanted to check out how the changes you made work really quickly and easily. Adding and using references, even nuget ones, can also be done right w/in the ScriptCS interpreter.

I created one Class Library project with this as its contents:

using System;

namespace ClassLibrary1
    public class Class1
        public void PrintNumbers()
            for (int i = 0; i < 10; i++)
                Console.WriteLine("#{0}", i);

Easy enough, build in to ClassLibrary1.dll, copy to c:\users\brandon and off I go:


Quickly and easily, I just prototyped my library and played around a bit.

I remember early versions of ScriptCS and it didn’t used to allow multi-line REPL. After some back and forth with Glenn Block (one of the founders) and a couple of the other team members, it was brought to my attention that indeed it does now!


So there you have it! Quick, easy, C# with nothing more than a command line! Be sure to check out the ScriptCS website and Github project area to learn more about what you can do with it and how to do it!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
I'm a Sr. Software Engineer in the Seattle area primarily focused on serverless technologies in the cloud. In my free time I enjoy hiking & other adventures with my family around the Puget Sound and the country! You can find out more about me at my homepage:

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Volynsky Alex23-Apr-14 9:55
professionalVolynsky Alex23-Apr-14 9:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 23 Apr 2014
Article Copyright 2014 by BC3Tech
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid