Deep dive into .NET Standard

Most of us are familiar with .NET Framework, .NET Core and .NET Standard applications. .NET Framework is an .NET implementation that supports websites, services apps, and more on windows. But .NET Core is a cross-platform .NET implementation for websites, servers and console apps on Windows, Linux and macOS. And also Xamarin is an .NET implementation which is used to develop cross platform mobile applications. 

Moreover, the base libraries for .NET Framework, .NET Core and Xamarin are different. In this blog we’ll see an detailed description of .NET standard. And also we’ll see how we can integrate it with Framework, Core application and Xamarin applications.

What is .NET Standard

It provides us the specification of .NET API’s which are available on all .NET implementations. The aim of .NET Standard is to provide an uniformity across the .NET implementations.

It provides us the following advantages,

  • It defines uniform set of BCL API’s that can be used for all .NET implementations, independent of workload.
  • It also can be used to produce portable libraries which can be used for all .NET implementations by using the same set of API’s.
  • It eliminates or reduces conditional compilation of shared source due to .NET API’s.

.NET implementation support

The following table lists the .NET Standard supported version for various implementations.


If you want to see the live update of this table you can check out this link.

Which version to target?

When you select your library version for your .NET implementation just keep two things in mind.

  • Higher the version, the more API’s available.

  • Lower the version, the more platforms implement it.

However Microsoft recommends to target us the lower version of .NET Standard because it introduces a number of support dependencies.

Creating .NET Standard project using Visual Studio

Install any edition of Visual Studio 2017 from visualstudio.com with any .NET-related workload. To create an .NET Standard follow the below steps:

  1. In Visual Studio 2017, choose File -> New -> Project, expand the Visual C# > .NET Standard node, select the “Class Library(.NET Standard)” template, give any name to your project, and click OK. 
  2. You can write your business logic into the class library project. In this example, we’ll just create an library project that just return the sum of two numbers. 
    using System;
    
    namespace AdditionOfTwoNumbers
    {
        public class AdditionOfTwoNumbers
        {
            public int Add(int numberOne, int numberTwo)
            {
                 return numberOne + numberTwo;
            }
        }
    }
    
  3.  Right-click on the resulting project file and select Build to make sure the project was created properly. The DLL will be found within the Debug folder (or Release if you build that configuration instead). 

    4. The respective dll file can be used for both .NET Framework and .NET Core projects.

These are some interesting information’s of .NET Standard. In our next blog we’ll see what are all the new features introduced in .NET Standard 2.0.

Stay tuned for TechMeet360 for more interesting updates.

Happy Coding!

Cheers! 🙂

Author: Suhas Parameshwara

Suhas Parameshwara is a Full Stack Web Application Developer working with Kovai.Co. He acquired a Bachelor's Degree in Computer Science from Sri Eshwar College of Engineering, Tamil Nadu (Coimbatore). He has around 3+ years of experience in Microsoft Technologies such as C#, ASP.NET, .NET Core, SQL, Azure, Visual Studio, Visual Studio Code, and UI technologies such as HTML, CSS, JS, and Angular. He is also a Blogger and a Speaker and tries to grab all the opportunities to stay connected with the technical community. For his continuous contribution to the community, he has been recognized as Microsoft MVP for Developer Technologies Category from 2020.

Get notified about any future events

Interested in learning more about TechMeet360 or knowing about any future events? Sign up below to get notified.

Back to Top