C# Console/CLI Interpreter?

后端 未结 17 1897
眼角桃花
眼角桃花 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:13

    If you're using Mono, there's this:

    CsharpRepl

    Don Box hacked something very simple up a few years ago too.

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

    Try scriptcs, it's not integrated into the VS IDE but it does let you type and run C# in a script window without the need for a project compiler etc...

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

    I also find that SharpDevelop is so quick and lightweight that it is the easiest way to whip off a quick test project.

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

    As you suggest, PowerShell can do what you want. For example, to test your DateTime.Parse, the following one liner will do the trick:

    PS C:\Documents and Settings\Dan> [System.DateTime]::Parse("Blah")
    Exception calling "Parse" with "1" argument(s): "The string was not recognized as a valid DateTime. There is a unknown word starting at index 0." At line:1 char:25 + [System.DateTime]::Parse( <<<< "Blah")

    PS C:\Documents and Settings\Dan> [System.DateTime]::Parse("1/2/3")

    01 February 2003 00:00:00

    Note that the above uses the current release of PowerShell (v1.0). The next version of PowerShell will allows you to intermingle C# with PowerShell scripts more directly. To whet your appetite, watch this 7 minute screencast "C# to PowerShell" by Doug Finke. Very impressive!

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

    The Mono project includes an interactive C# shell, this may be just what you're looking for.

    http://www.mono-project.com/CsharpRepl

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