Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to reference two identically named namespaces?

Tags:

c#

.net

The title should say it all...

EDIT: Apparently the title didn't say it all, but Jon Skeet was able to figure out what I meant anyway!

like image 249
Dan Byström Avatar asked Dec 12 '25 07:12

Dan Byström


1 Answers

Assuming you mean you want to refer to types in the same namespace (or even the same fully qualified type name) provided by two different assemblies, you can do this from C# 2 and up using extern aliases.

Ideally you should try to avoid getting into this situation, but you can do it if you really, really need to.

Anson Horton has a blog post about extern aliases and using them from Visual Studio.

like image 89
Jon Skeet Avatar answered Dec 14 '25 19:12

Jon Skeet