Initializing the C# interactive session from the existing C# project
In this section, we will walk you through the steps to initialize a C# interactive scripting session from an existing C# project and then use the types from the project in the Visual Studio interactive window.
Getting started
You will need to have Visual Studio 2017 Community edition installed on your machine to execute this recipe. You can install a free community edition from https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15.
How to do it...
- Open Visual Studio and start the
C# Interactive
window by clicking onView |
Other Windows |
C# Interactive
. - Declare a local variable
int x = 0;
in the interactive window and press the Enter key. - Execute
Console.WriteLine(x)
and verify the output0
to confirm that the variablex
is declared in the current session. - Create a new C# class library project, say
ClassLibrary
. - Add the following method
M
to typeClass1
in the created project:
public void M()...