Anders Hejlsberg's C# 4.0 REPL

前端 未结 10 675
甜味超标
甜味超标 2020-12-13 04:05

During the last 10 minutes of Ander\'s talk The Future of C# he demonstrates a really cool C# Read-Eval-Print loop which would be a tremendous help in learning the language.

相关标签:
10条回答
  • 2020-12-13 04:27

    I just published a VisualStudio Extension that provides a REPL environment inside VisualStudio (namely a C# REPL Environment with a Fluent API for .NET and VisualStudio)

    In addition to being able to write and execute quick C# snippets (in a REPL environment), you can program VisualStudio IDE in real time!

    You can install it using VisualStudio's Extension Manager (search for C# REPL) or via the download link at the VisualStudio Gallery page: VisualStudio C# REPL

    The VisualStudio C# REPL page also contains more details and code samples.

    There is also an Reddit thread on this extension (which contains more code samples).

    Let me know what you think of it

    0 讨论(0)
  • 2020-12-13 04:32

    From time to time I want to try out some .NET API instead of wondering about C# language syntax. (There are far more subtleties in API than in the language itself.) If you are only looking for REPL for .NET, good old PowerShell is always with you.

    C#:

    using System;
    using System.Text;
    
    Convert.ToBase64String(Encoding.UTF8.GetBytes("Overflow"));
    

    PowerShell:

    [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("Overflow"))
    
    0 讨论(0)
  • 2020-12-13 04:36

    The REPL demo was part of "what might happen next", i.e. after 4.0; in .NET 5.0 or something similar.

    This is not 4.0 functionality, and never has been.

    0 讨论(0)
  • 2020-12-13 04:38

    Take a look at this C# REPL Script Environment which is a great way to quickly run C# script (and learn how to code)

    0 讨论(0)
  • 2020-12-13 04:41

    Marc's answer is entirely correct, the possibility of a repl or script like c# has been discussed by Eric Lippert in two blog posts:

    • Why doesn't c# implement top level methods
    • It already is a scripting language

    I would add that, the 2010 CTP does contain an f# repl (not much use for c# but if you were interested in some aspect of the BCL or CLR then it might be sufficient for your needs)

    I find that LINQPad makes up for the lack of a REPL in many cases. It would be nice to get it integrated into Visual studio so you could interact with your existing code base more easily though.

    0 讨论(0)
  • 2020-12-13 04:46

    It's probably worth mentioning that the Mono project already does have a C# REPL which i tend to use for those small checks you do now and then. Take a look. Also, if I'm testing an idea which I'm uncomfortable Mono is going to handle to well and it's not worth starting a new test project then Snippet Compiler always comes in handy.

    0 讨论(0)
提交回复
热议问题