Home

Welcome to trycsharp.org

Welcome to C# REPL

This project aims at building an interactive interpreter for C#, implemented as a console application.

Blog posts about CSRepl

Please provide feedback in the comment section.

Roadmap

Roadmap

Features

Support includes, but does not stop at:

Literal expressions:

> 1 + 2
3
> 2 * 4
8
> "hello, world"
"hello, world"

Semicolon is optional:

> 1 + 2
3
> 1 + 2;
3

Sequence of statements:

> var x = 1
> x
1
> x = 2
2

Collections:

> new[] {1,2,3}
[1,2,3]
> var list = new List<int> {1,2,3}
> list
[1,2,3]

> var map = new Dictionary<int, string> {{1,"foo"},{2,"bar"}}
> map
[[1, "foo"],[2, "bar"]]

Method declarations:

> int Foo() { return 1; }
> Foo()
1

Type declarations:

> class Foo { public string Bar() { return "Bar"; } }
> var foo = new Foo()
> foo.Bar()
"Bar"

Multi line statements:

> class Foo
> {
>    public int AddOne(int v)
>    {
>        return v + 1;
>    }
> }
> var foo = new Foo()
> foo.AddOne(1)
2

Using statements:

> new ArrayList() {1}
The type or namespace name 'ArrayList' could not be found
> using System.Collections
> new ArrayList() {1}
[1]

Formatting of complex types:

> class Foo { public string Bar { get; set; } }
> var foo = new Foo { Bar = "Hello" }
> foo
Foo { Bar = "Hello" }
>
> var anonymous = new { X = 1, Y = "foo" }
> anonymous
{ X = 1, Y = foo }
>
> var xml = new XmlDocument();
> xml.LoadXml("<foo bar=\"baz\" />")
> xml
<foo bar="baz" />

Load external assemlies:

> LoadAssembly("ICSharpCode.SharpZipLib.dll")
> using ICSharpCode.SharpZipLib.Zip
> new FastZip()
FastZip { CreateEmptyDirectories = False,  Password = null,  NameTransform = ZipNameTransform { TrimPrefix = null },  EntryFactory = ZipEntryFactory { NameTransform = ZipNameTransform { TrimPrefix = null },  Setting = LastWriteTime,  FixedDateTime = 2012-01-01 12:36:13,  GetAttributes = -1,  SetAttributes = 0,  IsUnicodeText = False },  UseZip64 = Dynamic,  RestoreDateTimeOnExtract = False,  RestoreAttributesOnExtract = False }

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.