What is .NET Standard?
π‘ Concept Name
.NET Standard
π Quick Intro
.NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementationsβsuch as .NET Framework, .NET Core, and Xamarin.
π§ Analogy / Short Story
Imagine .NET Standard as a shared agreement or contract. Itβs like a universal remote that works across all TV brands. Whether you use a Sony, Samsung, or LG (i.e., .NET Framework, Core, or Xamarin), the remote (API) behaves the same.
π§ Technical Explanation
.NET Standard defines a set of APIs that all .NET platforms must implement. It helps in building libraries that can run on multiple .NET runtimes without rewriting code. Each version of .NET Standard adds more APIs and determines the compatibility level across frameworks.
π― Purpose & Use Case
- β Share code across .NET Framework, .NET Core, Xamarin
- β Avoid duplication in class libraries
- β Simplify multi-platform library development
- β Ensure forward compatibility and ecosystem standardization
π» Real Code Example
Creating a Class Library with .NET Standard
// Create a .NET Standard class library:
// dotnet new classlib -n SharedLibrary -f netstandard2.0
// MyService.cs
namespace SharedLibrary
{
public class MyService
{
public string GetInfo() => "This works across all .NET platforms!";
}
}

β Interview Q&A
Q1: What is .NET Standard?
A: A specification of APIs common across all .NET implementations.
Q2: Why was .NET Standard introduced?
A: To allow code sharing across different .NET platforms.
Q3: Is .NET Standard a runtime?
A: No, it's just a specification, not an actual implementation.
Q4: What are some alternatives to .NET Standard now?
A: .NET 5+ uses a single runtime, so .NET Standard is less required now.
Q5: Can a .NET Standard library run on .NET Framework?
A: Yes, if the framework supports the .NET Standard version used.
Q6: Which command creates a .NET Standard library via CLI?
A: dotnet new classlib -f netstandard2.0
Q7: What version of .NET Standard is most widely supported?
A: .NET Standard 2.0
Q8: Can I use third-party NuGet packages in .NET Standard library?
A: Yes, if they target the same or lower version of .NET Standard.
Q9: What's the benefit over Portable Class Libraries (PCL)?
A: .NET Standard is simpler, broader in support, and future-focused.
Q10: Should I still use .NET Standard today?
A: Use it if you need to support older frameworks; otherwise use .NET 6/7 class libs.
π MCQs
Q1. What is .NET Standard?
- .NET runtime
- A C# version
- A formal specification of common .NET APIs
- A Microsoft Visual Studio template
Q2. Why was .NET Standard created?
- To speed up apps
- To replace NuGet
- To enable code sharing across .NET platforms
- To reduce app size
Q3. Is .NET Standard a runtime environment?
- Yes
- Only in .NET Core
- No
- Depends on SDK
Q4. Which .NET Standard version is widely supported?
- 1.0
- 2.0
- 2.1
- 3.0
Q5. What does a .NET Standard library contain?
- Web services
- Cross-platform compatible APIs
- XAML UIs
- SQL scripts
Q6. Can you use NuGet packages in .NET Standard?
- No
- Yes, if versions match
- Only on Windows
- Only in .NET 5+
Q7. Is .NET Standard still relevant in .NET 6+?
- No
- Yes, always
- Only for compatibility with old platforms
- Only for Web APIs
Q8. What replaces .NET Standard in .NET 5+ world?
- Mono
- .NET Framework 4.8
- Blazor
- Unified .NET platform
Q9. Can you target Xamarin using .NET Standard?
- No
- Yes
- Only partially
- Not anymore
Q10. Does .NET Standard ensure API availability?
- No
- Depends on platform
- Yes
- Only in Core
π‘ Bonus Insight
While .NET Standard is being replaced by .NET 5/6/7+'s unified model, it still plays a vital role when targeting old runtimes. Think of it as the glue that once unified the fragmented .NET ecosystem.
π PDF Download
Need a handy summary for your notes? Download this topic as a PDF!