It’s hard to read an intro to .NET Core without someone also introducing .NET Standard and then quickly moving on, leaving you to wonder just what is the .NET Standard. I’ve seen the same questions come up over and over again. Is it another framework I have to learn? Is it the old .NET? Is .NET Standard and .NET Core the same? Hopefully we can answer all those questions today!

.NET Standard Is Exactly That. A Standard.

.NET Standard is for lack of a better word, a standard. It’s a description of the core interfaces that every .NET platform should implement if they wish to say “I support .NET Standard 2.0” for example.

An easy way to see what exactly the standard defines is actually the nuget package here : https://www.nuget.org/packages/NETStandard.Library . If you scroll down you will see descriptions of what each standard defines. So for example, .NET Standard 1.1 introduces System.Linq. If you would like to use System.Linq, you will need to use a platform that implements .NET Standard 1.1.

That brings us to the next point….

What Is A Platform?

It’s may be also good to take a step back and look at what exactly is a platform. At the moment the Microsoft .NET platform list looks like.NET Framework (Old .NET), .NET Core, Xamarin, Universal Windows Platform (UWP), Windows Phone and now also Mono.

Each platform version will implement a specific .NET Standard version. So for example, .NET Framework Version 4.6 implements the .NET Standard 1.3, whereas .NET Core Version 1.0 implements .NET Standard 1.6. If I were to write a library that I wanted a developer to use in both .NET Framework Version 4.6 and .NET Core Version 1.0, then I would have to target the lowest .NET Standard that these platforms implement. That being .NET Standard 1.3 in this case.

Microsoft have released an easy to view “chart” that tells you which version of each platform implements each version of the standard. You can see it here.

It’s important to note that each platform can implement it’s own features. Windows Phone for example may implement phone specific classes and interfaces, but it will also expose a classes and interfaces of it’s corresponding .NET Standard.

When Do You Have To Worry About It?

If you are writing for a particular platform, you usually don’t have to worry about .NET Standard at all. You may at times wish to look up the standard to see what would be coming to your platform next release, but that’s about it.

If you are developing your own library that you wish to be used across multiple platforms, that’s when the .NET Standard comes in handy. If you write a library that you want working on .NET Core, UWP, Windows Phone and .NET Framework, you will need to only use classes that are available on all of those platforms. How do you know what classes are available on all platforms? The .NET Standard!

What we will likely see in the future from library developers is the requirements changing from “You need .NET Framework version 4.6” to, “This is built on top of .NET Standard 1.6”. And from there you can go and look up what platforms use that standard.

A Web Analogy

Let’s try and think about this in a web sense. It’s not a direct analogy, but we’ll try. Let’s take ECMAScript or Javascript as an example. ECMAScript is a standard. It’s defined in a way that browsers then have to implement. Each browser implements ECMAScript, but they can also do their own things on top (In terms of favourites, addons, plugins etc). This is similar to how a .NET platform would work, they implement the standard, but then they can add their own platform specific items on top.

Now if you are writing a website and you wish to use a certain feature of javascript, you have to look at what browsers have implemented that feature. Then you make the decision, either you support “old” browsers, or you only outlay your support for certain modern browsers. This is similar to how it would work if you were writing a .NET library. You look at what platforms you wish to support, but if they are old, crusty and are only implementing an old version of the .NET Standard, then you can forgo supporting that platform and target a higher standard.

There is one big difference however. Unlike ECMAScript (And other web technologies like CSS), it’s hoped that platforms implement an all or nothing approach when it comes to moving up the .NET standard ladder. Either you implement .NET Standard 1.5 or 1.6, but you don’t release a platform version that implements 1.5 and a few features from 1.6. Remember, .NET Standard is supposed to make it “easy” to determine what classes and interfaces you have available.

Questions?

I’ll admit, I’m still wrapping my head around how .NET Standard works. But it’s early days yet. You can go to the Microsoft Github and see people still discussing how things should work long term, so it’s not just your everyday developer trying to work it out. If you have any questions feel free to comment below and I’ll do my best to answer.