The code I'm working with has a class called Environment that is not in any namespace. Unfortunately if I am in a class that imports the System namespace, there is no way to refer to the custom class called Environment. I know this was an unfortunate choice and should be refactored, but is there any way I can explicitly refer to the conflicting class?
In C++ it seems the way to do this is by using ::, and in Java there is something called global:: How do I do it in C#?
C# also has a global (or unnamed) namespace - you can use global::
to access your class:
global::Environment
See more on MSDN. Also see the ::
operator.
You can create an alias for it as well:
using myEnv = global::Environment; using sysEnv = System.Environment;
Should be global::Environment
just like in Java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With