Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development

You're reading from   C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development Create powerful applications with .NET Standard 2.0, ASP.NET Core 2.0, and Entity Framework Core 2.0, using Visual Studio 2017 or Visual Studio Code

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher
ISBN-13 9781788398077
Length 800 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mark J. Price Mark J. Price
Author Profile Icon Mark J. Price
Mark J. Price
Arrow right icon
View More author details
Toc

Table of Contents (24) Chapters Close

Preface 1. Hello, C#! Welcome, .NET Core! FREE CHAPTER 2. Part 1, C# 7.1
3. Speaking C# 4. Controlling the Flow and Converting Types 5. Writing, Debugging, and Testing Functions 6. Building Your Own Types with Object-Oriented Programming 7. Implementing Interfaces and Inheriting Classes 8. Part 2 – .NET Core 2.0 and .NET Standard 2.0
9. Understanding and Packaging .NET Standard Types 10. Using Common .NET Standard Types 11. Working with Files, Streams, and Serialization 12. Protecting Your Data and Applications 13. Working with Databases Using Entity Framework Core 14. Querying and Manipulating Data Using LINQ 15. Improving Performance and Scalability Using Multitasking 16. Part 3 – App Models
17. Building Web Sites Using ASP.NET Core Razor Pages 18. Building Web Sites Using ASP.NET Core MVC 19. Building Web Services and Applications Using ASP.NET Core 20. Building Windows Apps Using XAML and Fluent Design 21. Building Mobile Apps Using XAML and Xamarin.Forms 22. Summary 23. Answers to the Test Your Knowledge Questions

Writing and compiling code using Visual Studio Code

The instructions and screenshots in this section are for macOS, but the same actions will work with Visual Studio Code on either Windows or Linux. The main differences will be native command-line actions such as deleting a file: both the command and the path are likely to be different. The dotnet CLI tool will be identical on all platforms.

Writing code using Visual Studio Code

Start Visual Studio Code.

Navigate to File | Open..., or press Cmd + O.

In the dialog, open the Code folder, select the Chapter01 folder, click on the New Folder button, enter the name WelcomeDotNetCore, and click on Create. Select the WelcomeDotNetCore folder, and click on Open or press Enter.

In Visual Studio Code, navigate to View | Integrated Terminal, or press Ctrl + `.

At the TERMINAL prompt, enter the following command:

dotnet new console

You will see that the dotnet command-line tool creates a new console application project for you in the current folder, and the Explorer window shows the two files created, as shown in the following screenshot:

In the EXPLORER window, click on the file named Program.cs to open it in the editor window.

If you see the warnings mentioning that the required assets are missing, click on Yes, as shown in the following screenshot:

Modify the text that is being written to the console to say, Welcome, .NET Core!

Navigate to File | Auto Save. This toggle will save the annoyance of remembering to save before rebuilding your application each time!

Compiling code using Visual Studio Code

Navigate to View | Integrated Terminal or press Ctrl + `, and enter the following command:

dotnet run

The output in the TERMINAL window will show the result of running your application.

Autoformatting code

In Visual Studio Code, navigate to File | Open, and open the Chapter01 folder.

In Explorer, expand HelloCS, and select MyApp.cs.

Click on Yes, when prompted to add required assets.

In Visual Studio Code, either right-click and choose Format Document, or press Alt + Shift + F, as shown in the following screenshot:

Visual Studio Code is rapidly approaching feature parity with Visual Studio 2017 on Windows.

You have been reading a chapter from
C# 7.1 and .NET Core 2.0 ??? Modern Cross-Platform Development - Third Edition
Published in: Nov 2017
Publisher:
ISBN-13: 9781788398077
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image