.NET Standard vs Portable Class Library (PCL)
π‘ Concept Name
.NET Standard vs PCL (Portable Class Library)
π Quick Intro
Both PCL and .NET Standard were designed to enable code sharing across .NET platforms. However, .NET Standard simplifies this process and has effectively replaced PCLs.
π§ Analogy / Short Story
Imagine PCL as packing a suitcase for a trip with *specific airlines*βyou can only take what's allowed by all of them. .NET Standard, on the other hand, gives you a universal luggage listβpack once, use it on all airlines. Much simpler!
π§ Technical Explanation
- π¦ **PCL** targets *intersections* of APIs supported by selected platforms.
- π§© **.NET Standard** defines a *common set* of APIs all platforms must implement.
- π§ PCL was complex to maintain due to various profile combinations.
- π .NET Standard is easier to version, and supports broader platform compatibility.
- β PCL has been deprecated in favor of .NET Standard and .NET 5+.
π― Purpose & Use Case
- β Use .NET Standard to create reusable libraries across .NET Framework, .NET Core, Xamarin, and more.
- β Helps unify code for cross-platform apps.
- β Avoid PCLs in new projects β limited support and tooling.
π» Real Code Example
A .NET Standard class library can be referenced by multiple app types:
// MyLibrary.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
public class MathUtils {
public static int Square(int x) => x * x;
}

β Interview Q&A
Q1: What is the main purpose of .NET Standard?
A: To provide a uniform set of APIs for all .NET implementations.
Q2: What does a PCL target?
A: The common subset of APIs supported by selected .NET platforms.
Q3: Is PCL still recommended?
A: No, itβs deprecated.
Q4: Can .NET Standard be used with Xamarin?
A: Yes, fully supported.
Q5: What is a major downside of PCLs?
A: Complexity due to intersection-based profiles and limited API availability.
π MCQs
Q1. .NET Standard is preferred over PCL because:
- It’s older
- It uses more memory
- It provides a uniform API surface for all platforms
- It’s only for Xamarin
Q2. What does a PCL define?
- All APIs in .NET
- Common APIs supported by selected platforms
- Xamarin-specific APIs
- None of these
Q3. Which one is deprecated?
- .NET Standard
- PCL
- Both
- Neither
Q4. Is .NET Standard compatible with .NET Core?
- No
- Yes
- Only with converters
- Only in preview builds
Q5. What’s a key benefit of .NET Standard?
- Platform-specific APIs
- Low memory
- Cross-platform compatibility
- Better threading
π‘ Bonus Insight
With the evolution of .NET 5 and later, you donβt need to choose between .NET Standard and .NET Core β everything is unified under a single platform. Use .NET Standard only if you need compatibility with older runtimes.
π PDF Download
Need a handy summary for your notes? Download this topic as a PDF!