Assembly Vs Namespaces

Uzoamaka Nweze
1 min readNov 10, 2022

--

According to Microsoft, “A namespace keyword is used to declare a scope that contains a set of related objects.” This grouping of related elements helps avert the issue of name conflicts between classes of similar names.

Here are two examples that can help clarify:

namespace ScientificCalculator{public class Calculator{}}namespace SimpleCalculator{public class Calculator{}}

The first one has an order of ScientificCalculator.Calculator while the second one has an order of SimpleCalculator.Calculator.

Although they share similar class names, they won’t have issues compiling because of the presence of different namespaces associated with these classes.

Pro C# 10 with .NET 6 describes an assembly as the binary unit that contains managed codes. An assembly can also be described as the compiled code involving classes and other resources(namespaces included) that can be executed by the common language runtime.

With this definition, we can see that an assembly encompasses namespaces and everything included in a given project.

It’s also worthy of note that languages that run on .NET can use the same namespaces.

sources: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/namespace

Andrew Troelsen Phil Japikse, Pro C# 10 with .NET 6

--

--