简体   繁体   English

Mac 上 Visual Studio 社区中的 C# Interactive

[英]C# Interactive in Visual Studio Community on Mac

I'm trying to do some treehouse tutorials on C#.我正在尝试在 C# 上做一些树屋教程。 Unfortunately, the instructor is teaching this course in an windows machine with a windows version of VS Community while I follow along VS Community for mac.不幸的是,讲师正在带有 Windows 版本 VS Community 的 Windows 机器上教授这门课程,而我则关注 VS Community for mac。 Got to a point where she is trying to use the C# interactive (REPL) but I can't seem to find it on the mac version.到了她尝试使用 C# 交互式 (REPL) 的地步,但我似乎在 mac 版本上找不到它。 Anyone know if its even possible to do this on the mac?任何人都知道是否可以在mac上执行此操作? Thanks.谢谢。

You can't run it in Visual Studio.你不能在 Visual Studio 中运行它。 You can, however, use the terminal.但是,您可以使用终端。

When you install mono the command csharp gets installed as well.当你安装mono ,命令csharp也会被安装。 Simply type csharp and the terminal will become a C# interactive window.只需输入csharp ,终端就会变成一个 C# 交互窗口。

在此处输入图片说明

No Interactive Window support in VS 2017 Mac . VS 2017 Mac 中不支持交互式窗口。

Future versions may have this feature.未来的版本可能有这个功能。 If it is important you could use Parallels and run the Windows version.如果这很重要,您可以使用 Parallels 并运行 Windows 版本。

Or work around it by doing the same sorts of things with a debugger and Immediate Window.或者通过使用调试器和立即窗口做同样的事情来解决它。

If you have Mono installed you can also use: csi如果您安装了 Mono,您还可以使用: csi

csi 提示示例

Use Xamarin Workbooks !使用Xamarin 工作簿

If you don't like Xamarin Workbooks for whatever reason, you can also use csi in the console, but it doesn't have code completions :/ I couldn't edit Sachin's answer above, but to be more clear, all you need to do is open the terminal and type csi to start the C# interactive tool.如果您出于某种原因不喜欢 Xamarin 工作簿,您也可以在控制台中使用csi ,但它没有代码完成功能:/ 我无法编辑上面 Sachin 的答案,但更清楚的是,您需要做的就是做的是打开终端并输入csi以启动 C# 交互工具。 Of course this only works after you've installed Visual Studio (it should have installed Mono in the process).当然,这仅在您安装 Visual Studio 后才有效(它应该在此过程中安装了 Mono)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM