views:

76

answers:

2

Let's say I have a DLL that provides math calculus functions.

To use it, I include the using Colhq.Math.Basic; namespace.

How could I use it by adding a statement like using Blala.Functions.Math; ?

So how could I use everything (methods, enums, etc.) from a DLL by using a different namespace ? Is there a one-shot way to wrap or mask a DLL ?

+3  A: 

You can use a namespace alias.

Robert Harvey
Can this be used even if I do NOT have access to DLLs source code ?
ytrewq
@ytrewq: Yes. Read the link.
Matti Virkkunen
Yes, but the condition you gave Andrew seems to preclude the use of an alias. What are you trying to do, anyway? Hide someone else's DLL in your code? That doesn't seem prudent.
Robert Harvey
Yes, I want to use everything that is under a namespace with a different namespace. I want to provide the functionality within a DLL under a new namespace (the old namespace will not have to appear in the code that uses my wrapper DLL). Is this possible ?
ytrewq
A: 

Place the following at the top of each file where you need the alias:

using Blala.Functions.Math = Colhq.Math.Basic

Andrew Theken
I do NOT want `Colhq.Math.Basic` to appear in my source code;
ytrewq
This won't work. Aliases can only be represented by one identifier, not a succession of dotted ones like usual namespaces.
Julien Lebosquain