Can a C # interactive window interact with my code?

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

> 5 + 3 8 

It's cute. Now, how can I interact with my codes - my classes? Suppose the project is 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?) 
+144
c # visual-studio roslyn
Jun 21 2018-12-12T00:
source share
4 answers

When using Visual Studio 2015:

You can open the Interactive window by clicking on the link Views> Other Windows OS> C # Interactive ,

Then, simply right-click the project and run Initialize Interactive Project from the context menu.




For older versions:

To use the C # interactive window with code, make sure you compile your code first, and then add the link to the resulting assembly using the #r as follows:

C # command prompt




You can also use Immediate Window to interact with your code, for example:

Immediate Window

+187
Jun 21 '12 at 10:00
source share

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

If you need more information, here is the source:
Using the C # Interactive Window That Comes with Roslyn - Part 2

+66
Jun 21. 2018-12-12T00:
source share

Just an update from @ Botz3000's answer.

The command you want to find is now called Initialize Interactive Project

enter image description here

It is also worth noting that I could not find this command if my C # interactive window was not visible.

+39
Nov 17 '16 at 8:52
source share

Remember to change the class range, the name of the public class .
:)

+2
Apr 15 '17 at 19:33
source share



All Articles