Introduction to .NET Core

Sena Kılıçarslan
.NET Core
Published in
6 min readMar 29, 2019

I decided to start a series about .NET Core which has got remarkable attention in recent years and is increasing its popularity day by day as well as moving very fast. In this post, I will give general information about .NET Core and demonstrate how to build a console application using the framework. In the following posts, I am planning to write about ASP.NET Core MVC and build a web application and a REST API using this framework.

Before starting, I want to share with you that .NET Core is the most loved framework in the category of Other Frameworks, Libraries, and Tools according to the Stack Overflow Developer Survey Results 2019:

Source: https://insights.stackoverflow.com/survey/2019#most-loved-dreaded-and-wanted

Let’s start with defining .Net Framework, .Net Core and .Net Standard.

.Net Framework / .Net Core / .Net Standard

The .NET Framework is a development platform developed by Microsoft for building apps for web, Windows, Windows Phone, Windows Server, and Microsoft Azure. It consists of the common language runtime (CLR) and the .NET Framework class library, which includes a broad range of functionality and support for many industry standards. It runs primarily on Microsoft Windows. The first version of .NET Framework was released on 13 February 2002.

.NET Core is an open-source, general-purpose development platform maintained by Microsoft and the .NET community on GitHub. It’s cross-platform (supporting Windows, macOS, and Linux) and can be used to build device, cloud, and IoT applications. .NET Core 1.0 was released on 27 June 2016.

The .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations. The motivation behind the .NET Standard is establishing greater uniformity in the .NET ecosystem. When Microsoft shipped .NET Core 1.0, they also introduced .NET Standard.

.NET Core Fundamentals

.NET Core has the following characteristics:

  • Cross-platform: Runs on Windows, macOS and Linux operating systems.
  • Consistent across architectures: Runs your code with the same behavior on multiple architectures, including x64, x86, and ARM.
  • Command-line tools: Includes easy-to-use command-line tools that can be used for local development and in continuous-integration scenarios.
  • Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide. Can be used with Docker containers.
  • Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via .NET Standard.
  • Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. .NET Core is a .NET Foundation project.
  • Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support.

The following figure illustrates the components of .NET Core:

As you can see above, .NET Core includes .NET Compiler platform Roslyn, .NET Core runtime CoreCLR, .NET Core framework CoreFX and ASP.NET Core . (ASP.NET Core is a part of .NET Core SDK so you don’t need to install ASP.NET Core separately.)

The versions of .NET Core are as below:

You can download the latest version from here.

C#, Visual Basic, and F# languages can be used to write applications and libraries for .NET Core.

The ways of developing .NET Core apps are as follows:

When to Use .Net Core and .Net Framework

Use .NET Core for your server application when:

  • You have cross-platform needs.
  • You are targeting microservices.
  • You are using Docker containers.
  • You need high-performance and scalable systems.
  • You need side-by-side .NET versions per application.

Use .NET Framework for your server application when:

  • Your app currently uses .NET Framework (recommendation is to extend instead of migrating).
  • Your app uses third-party .NET libraries or NuGet packages not available for .NET Core.
  • Your app uses .NET technologies that aren’t available for .NET Core.
  • Your app uses a platform that doesn’t support .NET Core.

How Do Microsoft Think of .NET Framework and .NET Core Moving Forward?

Microsoft described their support for .NET Framework and .NET Core here as follows:

.NET Framework is the implementation of .NET that’s installed on over one billion machines and thus needs to remain as compatible as possible. Because of this, it moves at a slower pace than .NET Core. I mentioned above that even security and bug fixes can cause breaks in applications because applications depend on the previous behavior. We will make sure that .NET Framework always supports the latest networking protocols, security standards, and Windows features.

.NET Core is the open source, cross-platform, and fast-moving version of .NET. Because of its side-by-side nature it can take changes that we can’t risk applying back to .NET Framework. This means that .NET Core will get new APIs and language features over time that .NET Framework cannot. At Build I did a demo showing how the file APIs were faster on .NET Core. If we put those same changes into .NET Framework we could break existing applications, and we don’t want to do that.

We will continue to make it easier to move applications to .NET Core. .NET Core 3.0 takes a huge step by adding WPF, WinForms and Entity Framework 6 support, and we will keep porting APIs and features to help close the gap and make migration easier for those who chose to do so.

If you have existing .NET Framework applications, you should not feel pressured to move to .NET Core. Both .NET Framework and .NET Core will move forward, and both will be fully supported, .NET Framework will always be a part of Windows. But moving forward they will contain somewhat different features. Even inside of Microsoft we have many large product lines that are based on .NET Framework and will remain on .NET Framework.

How to Build a Console Application in .NET Core

Now that we have had general information about .NET Core, we can build our first application.

I have Visual Studio 2017 Community edition and .NET Core 2.2 on my computer.

First, let’s create a console application via File -> New -> Project…

After choosing Console App (.NET Core) and giving a name to the project, we press OK and the solution is created as below:

Program.cs is automatically created as follows

and prints “Hello World” when we run it as expected.

Let’s change the Program.cs and add some user interaction as below:

We get the following output after running the program:

It was easy, wasn’t it :) Hopefully, this post gave you a general idea about .NET Core, its advantages, where and when to use it.

In the next posts, we will dive into ASP.NET Core MVC and build applications using this framework.

Bye until then!

--

--

Sena Kılıçarslan
.NET Core

A software developer who loves learning new things and sharing these..