Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# 6 and .NET Core 1.0

You're reading from   C# 6 and .NET Core 1.0 Modern Cross-Platform Development

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781785285691
Length 550 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (20) Chapters Close

Preface 1. Hello, C#! Welcome, .NET Core! FREE CHAPTER 2. Speaking C# 3. Controlling the Flow, Converting Types, and Handling Exceptions 4. Using Common .NET Types 5. Using Specialized .NET Types 6. Building Your Own Types with Object-Oriented Programming 7. Implementing Interfaces and Inheriting Classes 8. Working with Relational Data Using the Entity Framework 9. Querying and Manipulating Data with LINQ 10. Working with Files, Streams, and Serialization 11. Protecting Your Data and Applications 12. Improving Performance and Scalability with Multitasking 13. Building Universal Windows Platform Apps Using XAML 14. Building Web Applications and Services Using ASP.NET Core 15. Taking C# Cross-Platform 16. Building a Quiz A. Answers to the Test Your Knowledge Questions B. Creating a Virtual Machine for Your Development Environment Index

Setting up your development environment

Before you start programming, you will need to set up your Interactive Development Environment (IDE) that includes a code editor for C#. The best IDE to choose is Microsoft Visual Studio 2015, but it only runs on the Windows operating system.

Using alternative C# IDEs

There are alternative IDEs for C#, for example, MonoDevelop, JetBrains Project Rider, and Microsoft Visual Studio Code. They each have versions available for Windows, Linux, and Mac OS X, allowing you to write code on one operating system and deploy to the same, or a different, one:

Cloud9 is a web browser-based IDE, so it's even more cross-platform than the others. here is the link:

https://c9.io/web/sign-up/free

In Chapter 15, Taking C# Cross-Platform, I will show you how to use Visual Studio Code running on Mac OS X to create an ASP.NET Core 1.0 web application that can be deployed to Windows, Mac OS X, or Linux operating systems, or to Docker containers.

Tip

Linux and Docker are popular server host platforms because they are relatively lightweight and more cost-effectively scalable when compared to operating system platforms that are designed for end users, such as Windows and Mac OS X.

Using Visual Studio 2015 on Windows 10

You can use Windows 7 or later to complete most of the chapters in this book, but you will have a better experience if you use Windows 10.

Tip

If you don't have Windows, I recommend that you create a virtual machine (VM) to use for development. You can choose any cloud provider, but Microsoft Azure has preconfigured VMs that include properly licensed Windows and Visual Studio 2015. You only pay for the minutes your VM is running, so it is a way for users of Linux, Mac OS X, and older Windows versions to have all the benefits of using Visual Studio 2015. Refer to Appendix B, Creating a Virtual Machine for Your Development Environment for more information.

Since October 2014, Microsoft has made a professional-quality edition of Visual Studio available to everyone for free. It is called the Community Edition.

Tip

Microsoft has combined all its free developer offerings in a program called Visual Studio Dev Essentials. This includes the Community Edition, the free level of Visual Studio Team Services, Azure credits for test and development, and free training from Pluralsight, Wintellect, and Xamarin.

Installing Microsoft Visual Studio 2015

Download and install Microsoft Visual Studio Community 2015 with Update 1 or higher.

Choosing the default installation

If you prefer a smaller, faster installation then choose Default because it only requires 8 GB and should complete the installation in about an hour. With this choice, as shown in the following screenshot, you will be able to complete the first two-thirds of this book. To complete the rest of the book, you can later add additional features, such as support for building Universal Windows Platform (UWP) apps, via Programs and Features in the Control Panel:

Choosing the default installation

If you chose Default, then skip to the Completing the Installation section.

Choosing the custom installation

If you have 34 GB of free disk space and can wait for several hours, then in the installation dialog, choose Custom, and then click on Next. Select the following features:

  • Under Windows and Web Development, tick the following checkboxes:
    • Microsoft SQL Server Data Tools
    • Microsoft Web Developer Tools
    • Universal Windows App Development Tools
  • Under Cross Platform Mobile Development, tick the following checkbox:
    • C#/.NET (Xamarin)
  • Under Common Tools, tick the following checkboxes:
    • Git for Windows
    • GitHub Extension for Visual Studio

Click on Next:

Note

If you have the Home edition of Windows 10, then you will not be able to install emulators for Windows Phone because they require Hyper-V support.

Choosing the custom installation

Tip

You can choose to install everything if you want support for languages such as C++, Python, and F#, but these will not be covered in this book.

Completing the installation

On the license terms dialog, click on Install. Wait for the files to download and install.

Tip

While you wait for Visual Studio to install, you can jump to the Understanding .NET Framework, .NET Core, and .NET Native section in this chapter.

Signing in to Visual Studio

The first time that you run Visual Studio, you will be prompted to sign in:

Signing in to Visual Studio

If you have a Microsoft account, for example, a Hotmail, MSN, Live, or Outlook e-mail address, you can use that account. If you don't, then register for a new one at the following link:

https://signup.live.com/

Choosing development settings

After signing in, you will be prompted to choose Development Settings. Choose Visual C# to configure keyboard shortcuts and a default window layout that works best for C# programmers, as shown in the following screenshot:

Choosing development settings

After you click on Start Visual Studio, you will see the Visual Studio user interface with the Start Page open in the central area. Like most Windows desktop applications, Visual Studio has a menu bar, a toolbar for common commands, and a status bar at the bottom. On the right is the Solution Explorer window that will list all of your open projects, as shown in the following screenshot:

Choosing development settings

To have quick access to Visual Studio in the future, right-click on its entry in the Windows taskbar and select Pin this program to taskbar:

Choosing development settings

Updating extensions and products

In the top-right corner of Visual Studio, you will see a flag that has a number next to it. These are notifications of extensions and product updates.

Click on the flag to display the Notifications window, as shown in the following screenshot:

Updating extensions and products

In the Notifications window, click on each entry to install the update. You can install these updates at a later time if you prefer, but it is best to keep your software up-to-date to avoid bugs and security holes. The following screenshot shows an extension downloading and installing:

Updating extensions and products

Using older versions of Visual Studio

If you want to use a free version of Visual Studio older than 2015, then you can use one of the more limited Express editions. A lot of the code in this book will work with older versions if you bear in mind when the following features were introduced:

Year

C#

Features

2005

2

Generics with <T>

2008

3

Lambda expressions with => and manipulating sequences with LINQ (from, in, where, orderby, ascending, descending, select, group, into)

2010

4

Dynamic typing with dynamic and multithreading with Task

2012

5

Simplifying multithreading with async and await

2015

6

string interpolation with $"", importing static types with using static, and other refinements.

You have been reading a chapter from
C# 6 and .NET Core 1.0
Published in: Mar 2016
Publisher:
ISBN-13: 9781785285691
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