C# Console/CLI Interpreter?

后端 未结 17 1896
眼角桃花
眼角桃花 2020-12-24 07:57

I wonder if there is something like a standalone Version of Visual Studios \"Immediate Window\"? Sometimes I just want to test some simple stuff, like \"DateTime.Parse(\"bla

相关标签:
17条回答
  • 2020-12-24 08:00

    Use LINQPad.

    Name notwithstanding, it can execute any C# or VB code, from simple expressions to entire classes.

    Plus, it can visualize entire object graphs in the results.

    You can even add references to your own assemblies.

    0 讨论(0)
  • 2020-12-24 08:01

    We've just released CShell a full featured C# REPL IDE. It supports code completion, script files, adding references and is really extensible. Also we plan to add NuGet support soon, which will make it super quick to write some code and see how it works.

    http://cshell.net/

    CShell screenshot

    We love LINQPad but it doesn't have a REPL, the code is executed once and you cannot do anything further with the results unless you modify the script and run the whole script again. This is okey, but sometimes if you want even more a scripty feeling then to evalute your code in a REPL is really nice and convenient.

    0 讨论(0)
  • 2020-12-24 08:01

    If you could wait a while.. it looks like there could be a C# equivalent of Ruby's irb in time for C# 4.0 Anders H. demonstrated an interactive console session where you could type in arbitrary C# code and see results in his 'Future of C#' piece at PDC 2008. You could even pop a WPF Window from it and then play with it via the console interface. Pretty cool.

    0 讨论(0)
  • 2020-12-24 08:01

    Try the C# REPL Script Environment that is part of the O2 Platform. It is exactly what you are asking for.

    It will give you a perfect environment to try out all C# features and APIs (conceptually the O2 REPL environment is similar to LinqPAD)

    You should also take a look at Roslyn from Microsoft. On Multiple Roslyn based tools (all running Stand-Alone outside VisualStudio) , the first one is a simple Roslyn REPL

    0 讨论(0)
  • 2020-12-24 08:03

    Update: http://avillenas.com/post/interactive-c

    Well, you can try this.

    1. Download and install dotnet.github.io
    2. Open cmd
    3. Type "dotnet repl"
    4. Type whatever you need.

    I did what you wanted to do. Click here to see the gif

    0 讨论(0)
  • 2020-12-24 08:04

    C# Interactive window and csi.exe REPL were added to Visual Studio 2015 Update 1:

    Introducing Interactive

    The Interactive Window is back! The C# Interactive Window returns in Visual Studio 2015 Update 1 along with a couple other interactive treats:

    • C# Interactive. The C# Interactive window is essentially a read-eval-print-loop (REPL) that allows you to play and explore with .NET technologies while taking advantage of editor features like IntelliSense, syntax-coloring, etc. Learn more about how to use C# Interactive on Channel 9 or by reading our beginner’s walkthrough.

    • csi. If you don’t want to open Visual Studio to play around with C# or run a script file, you can access the interactive engine from the Developer Command Prompt. Type csi /path/myScript.csx to execute a script file or type simply csi to drop inside the command-line REPL.

    • Scripting APIs. The Scripting APIs give you the ability to execute snippets of C# code in a host-created execution environment. You can learn more about how to create your own C# script engine by checking out our code samples.

    See What’s New in Visual Studio 2015 Update 1 for .NET Managed Languages.

    Basically, now you have:

    • IDE REPL — C# Interactive window in VS
    • Script interpreter — csi foo.csx from Dev Cmd Prompt
    • Command line REPL — csi from Dev Cmd Prompt
    • Scripting API
    0 讨论(0)
提交回复
热议问题