DEV Community

Francis Cote
Francis Cote

Posted on

16 4

.NET Standard explained to developers: What if it was an interface?

Quite recently, Microsoft shook the ground of the whole dotnet ecosystem with a new concept : .NET Standard. Lot's of folks like me, who already had a hard time keeping up with all things .NET lately, thought "What is it now?!".

Now, I spent a little while wrapping my head around this and I think I've come up with a developer-friendly explanation to what .NET Standard really is. In fact, I've somewhat materialized it into a little piece of (incomplete) code.

To dumb down things a bit, try to picture each version of .NET Standard as an interface, and each platform implementing them as classes. You'd get something like this :

interface INETStandard_1_0 { /* Lots of methods */ }
interface INETStandard_1_1 : INETStandard_1_0 { /* More methods */ }
interface INETStandard_1_2 : INETStandard_1_1 { /* More methods */ }
interface INETStandard_1_3 : INETStandard_1_2 { /* More methods */ }
interface INETStandard_1_4 : INETStandard_1_3 { /* More methods */ }
interface INETStandard_1_5 : INETStandard_1_4 { /* More methods */ }
interface INETStandard_1_6 : INETStandard_1_5 { /* More methods */ }
interface INETStandard_2_0 : INETStandard_1_6 { /* More methods */ }

// .NET Core Platform
class DotnetCore_1_0 : INETStandard_1_6 { /* Implements methods */ }
class DotnetCore_2_0 : DotnetCore_1_0, INETStandard_2_0 { /* Implements methods */ }

// .NET Framework Platform
class DotnetFramework_4_5 : INETStandard_1_1 { /* Implements methods */ }
class DotnetFramework_4_5_1 : DotnetFramework_4_5, INETStandard_1_2 { /* Implements methods */ }
class DotnetFramework_4_6 : DotnetFramework_4_5_1, INETStandard_1_3 { /* Implements methods */ }
class DotnetFramework_4_6_1 : DotnetFramework_4_6, INETStandard_2_0 { /* Implements methods */ }

// Mono Platform
class Mono_4_6 : INETStandard_1_6 { /* Implements methods */ }
class Mono_5_4 : Mono_4_6, INETStandard_2_0 { /* Implements methods */ }

// and so on...

Enter fullscreen mode Exit fullscreen mode

Now, in the facts, things are a bit more complicated since the API surface defined by .NET Standard includes classes as well as their members, but in essence that's really all this is: An interface, with several implementations.

If you're interested in this, you can head to the official repo where all the work is being done.

EDIT : Someone in the team just told me about David Fowler's take on the subject and of course it is awesome. I suggest you check this out too!

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (4)

Collapse
 
svick profile image
svick

The David Fowler version is also included in documentation of the .Net Standard repo: github.com/dotnet/standard/blob/ma....

Collapse
 
thatfrankdev profile image
Francis Cote

Totally missed it, thank's!

Collapse
 
insight_it_891bf8cd689700 profile image
Insight IT

Nice blog and informative content,
We are providing Best Dot NET Training in Hyderabad,
Thanks for sharing with us,
DOT NET Training in Hyderabad
DOT NET Online Training in Hyderabad

Collapse
 
unruledboy profile image
Wilson Chen

great minds think alike.

the official explanation: docs.microsoft.com/en-us/dotnet/st...

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay