C# 有交互式解释器吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2058715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there an interactive interpreter for C#?
提问by Seth
Sometimes it's handy to have access to your language to do quick things without starting Visual Studio and creating a new console app.
有时,无需启动 Visual Studio 和创建新的控制台应用程序,即可访问您的语言来快速完成任务。
Is there something like Python's interactive mode or groovy shell, except for C#?
除了 C# 之外,是否有类似 Python 的交互模式或 groovy shell 之类的东西?
回答by Jon Skeet
Have a look at CsharpRepl(part of the Mono project). Never used it myself, I hasten to add.
看看CsharpRepl(Mono 项目的一部分)。自己没用过,赶紧补充。
For LINQ stuff, you should also look at LINQPad.
对于 LINQ 的东西,你还应该看看LINQPad。
回答by David Basarab
Here is a Mono CsharpReplwhich is what you are looking for.
这是您正在寻找的 Mono CsharpRepl。
This documents the features available in the C# interactive shell that is part of Mono's C# compiler. An interactive shell is usually referred to as a read eval print loop or repl. The C# interactive shell is built on top of the Mono.CSharp (http:/monodoc/N:Mono.CSharp) library, a library that provides a C# compiler service that can be used to evaluate expressions and statements on-the-fly.
本文档记录了作为 Mono 的 C# 编译器一部分的 C# 交互式 shell 中可用的功能。交互式 shell 通常被称为 read eval 打印循环或 repl。C# 交互式 shell 构建在 Mono.CSharp (http:/monodoc/N:Mono.CSharp) 库之上,该库提供 C# 编译器服务,可用于即时评估表达式和语句。
回答by David Basarab
回答by Joey
Like others noted, Mono's CSharpRepl is probably the right answer. However, if you're not fixed to C#, then PowerShellis a pretty nice environment of playing around with .NET. I frequently use it to test regular expressions, format strings, etc. All the kinds of stuff you have ConsoleProject163 lying around for :)
就像其他人指出的那样,Mono 的 CSharpRepl 可能是正确的答案。但是,如果您不习惯使用 C#,那么PowerShell是一个非常适合玩 .NET 的环境。我经常用它来测试正则表达式、格式字符串等。你有 ConsoleProject163 的所有类型的东西:)
回答by Craig Stuntz
In addition to the other good answers here (+1), there is also CSIand the immediate windowin Visual Studio.
回答by Kristian Damian
回答by Daniel Rose
With the Visual Studio 2015 Update 1there now is a C# Interactive tool window built into Visual Studio.
在Visual Studio 2015 Update 1 中,现在有一个内置于 Visual Studio 的 C# 交互工具窗口。
The new tool window is invoked by going to View
→ Other Windows
→ C# Interactive
.
通过转到View
→ Other Windows
→调用新工具窗口C# Interactive
。
For Visual Studio 2010 to 2013 you can use the Roslyn CTPto get a similar tool window in Visual Studio.
对于 Visual Studio 2010 到 2013,您可以使用Roslyn CTP在 Visual Studio 中获得类似的工具窗口。
回答by Pinky
If you are looking for a simple web based environment to crank out some C# code try coderpad.ioNot sure if you can add libraries n' all but its a quick and simple solution if you are just interested in testing out several commands
如果您正在寻找一个简单的基于 Web 的环境来生成一些 C# 代码,请尝试使用coderpad.io不确定您是否可以添加所有库,但如果您只是对测试几个命令感兴趣,它是一个快速而简单的解决方案
回答by Gregor Schmitz
With Roslyn CTP there now is a full C# interactive window from Microsoft direct in Visual Studio!! Works great! So far runs all my libraries. After install: Invoking View -> Other Windows -> C# Interactive from the menu.
使用 Roslyn CTP,现在可以在 Visual Studio 中直接从 Microsoft 提供一个完整的 C# 交互式窗口!!效果很好!到目前为止运行我所有的库。安装后:从菜单中调用 View -> Other Windows -> C# Interactive。