可以和我的code中的C#交互窗口交互?我的、窗口、code

2023-09-03 11:09:50 作者:风不问归期

我装罗斯林。现在,如果我知道去哪里找在Visual Studio中,我可以打开C#交互窗口,并运行code:

 > 5 + 3
8
 

这就是可爱。现在,我怎么能互动的我的code 的 - 我的班?假设我有一个项目开放。

 >新的齿轮()
(1,5):错误CS0246:(?是否缺少using指令或程序集引用)类型或命名空间名称'齿轮'找不到
 

解决方案 微软 VS Code 1.58 版本发布,带来大量改进

您可以使用类从自己的项目。 只需右键点击你的解决方案,并选择从项目复位互动。

如果您需要了解更多信息,这里是源: Using C#的互动窗口,配备了罗斯林 - 第2部分

I installed Roslyn. Now, if I know where to look in Visual Studio, I can open the 'C# interactive window', and run code:

> 5 + 3
8

That's cute. Now how can I interact my code—my classes? Assume I have a project open.

> new Cog()
(1,5): error CS0246: The type or namespace name 'Cog' could not be found (are you missing a using directive or an assembly reference?)

解决方案

You can use classes from your own project. Just right click on your solution and select "Reset Interactive from Project".

If you need more information, here is the source: Using the C# Interactive Window that comes with Roslyn – Part 2