Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
A Package and Library are both relevant topics in C# programming.

However, what exactly does a Package contain and what exactly does a Library contain?
Also, what is the difference between a Package and a Library?

What I have tried:

C# Langauge, Programming, Visual Studio 2019
Posted
Updated 15-Sep-21 16:42pm
v5
Comments
PIEBALDconsult 15-Sep-21 15:52pm    
Neither has specific meaning in C#.
BillWoodruff 16-Sep-21 1:12am    
Here we go again ! Don Quixote charges another windmill :)

1 solution

A Package is mostly delivered by a Package manager like NuGet, see: NuGet Gallery[^]
A Package can contain anything, e.g. a library.
A library can be a .NET library, see: .NET class library overview | Microsoft Docs[^]
but it can also be a 3rd party library, or you can create your own library, see:
Create a .NET class library using Visual Studio - .NET | Microsoft Docs[^]
 
Share this answer
 
Comments
CBennigton 15-Sep-21 16:34pm    
After reading the statement you made "A Package is mostly delivered by a Package manager like NuGet", I did more digging on that and I actually came across the following Microsoft documentation https://docs.microsoft.com/en-us/nuget/what-is-nuget which states "Often such code is bundled into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages". It also stated "a NuGet package is a single ZIP file with the .nupkg extension"

A Package is a physical thing (being a single ZIP file with the .nupkg extension) and is container for assemblies (dll files). Without your input I probably would not have been able to figure that out. Thank you.

As for what is a Library and what it contains, after inspecting the links you provided it still did not make sense to me. Specifically when looking into the link "Create a .NET class library using Visual Studio"

It gave me the impression that a Library is an "application project" that we create. Then when looking into the code examples it has a namespace and a class called "UtilityLibraries" and "StringLibrary".

So then what exactly is a Library? Is it an application project, a namespace, or a class type?
raddevus 15-Sep-21 17:05pm    
Library is probably more conceptual. You may have something like the .NET library which is made up of one or more packages (physical downloadable DLLs).
So a library is a broad term that envelops the conceptual idea of one or more packages that solve a specific problem.
A Graphics Library provides functionality that helps you do drawing in your app (lines, rectangles, etc). And to use that library you download the physical DLLs (aka Assemblies in .NET) which are generally known as packages.
and they are known as packages more now because of NPM (node package manager) and nuget (.NET package manager).
CBennigton 15-Sep-21 20:50pm    
"You may have something like the .NET library which is made up of one or more packages (physical downloadable DLLs)." ---> Are you saying that a Library is a container for packages?
raddevus 15-Sep-21 20:58pm    
I’m saying it is a concept, an idea, a classification, a model or way of thinking about functionality that is grouped together. That’s it. You can say , “I downloaded a library” but you really downloaded DLLs that contain functionality that has been grouped together. A library is really only conceptual not physical.
CBennigton 15-Sep-21 21:20pm    
Oh ok, now I understand what you meant. Thank you correcting me on that :)

However, a "Package" unlike a "Library" does have a physical form correct? Being a single ZIP file with the .nupkg extension and is container for assemblies (dll files)?

The Microsoft documentation https://docs.microsoft.com/en-us/nuget/what-is-nuget states ---> "Often such code is bundled into "packages" that contain compiled code (as DLLs) along with other content needed in the projects that consume these packages". It also stated "a NuGet package is a single ZIP file with the .nupkg extension"

Unless I am totally misinterpretting the above statement made in the MS document.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900