Introduction to the C# Interactive and LINQPad tools

C# Interactive is a read-eval-print-loop (REPL) tool that is commonly ignored by many developers who use Visual Studio, but it has amazing functionality that will help you experiment with a notion quickly before you implement it. You can use it to play around with C# language features and any .NET technologies. For example, if you are not too sure how a certain ASP.NET Core 3 feature works, you can reference it in the pane and, interact with it, and view the output immediately. This makes it much easier and faster than experimenting with a full application.

In the following simple example, we'll declare a function called SquareNumber, which takes in an integer, x, multiplies it by itself, and gives us the answer when it's called in the next line:

With its high interactivity, you can write and test scripts and get an output immediately, which you can then use by just copying your code into the pane and pasting it into a script file that you name with the .csx extension; you can then run it through the Developer Command Prompt with the csi keyword.

You can also use C# Interactive to learn about external APIs that you can play around with interactively, but this is beyond the scope of this book.

In Chapter 9, Accessing Data Using Entity Framework Core 3, we will use LINQPad to demonstrate how to work with and debug LINQ queries. This is the right moment to introduce LINQPad, which can be downloaded from https://www.linqpad.net/.

Please note that LINQPad 5 supports .NET Framework and that LINQPad 6 supports the .NET Core 3.0 SDK.

LINQPad can be used for many other things, including as a testing ground for statements, expressions, and scripts in Microsoft's major languages (C#, F# and VB.NET), but our interest lies in using it to help us understand Language-Integrated Queries (LINQs) when we tackle that subject in Chapter 9, Accessing Data Using Entity Framework Core 3

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.184.42