5 ms·
in one file declare namespace foo { class Bar ... } In another file declare namespace foo { class Bar ... } Now use both foo.Bar
by greggman3 6y ago
in one file declare
namespace foo {
class Bar ...
}
In another file declare
namespace foo {
class Bar ...
}
Now use both foo.Bar from file 1 and foo.Bar from file 2 in the same project. Aliases don't help with this
- manigandham 6y agoDifferent assemblies with the same assembly name, namespace and class? Use an extern alias (which is how different versions of the same assembly can be used if necessary): https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias https://docs.microsoft.com/en-us/dotnet/csharp/language-refe... Different assemblies with different assembly names but same namespace and class? Just use the fully qualified type name (and alias it for a shorter name). Single assembly/project and namespace with the same class in multiple files? If you're just spreading out the code then use partial classes, otherwise why would you define the same type twice? C# (and other languages) that use virtual namespaces can do everything that file-based namespaces can do, but also support many more scenarios.