<1> The namespace hierarchy takes precedence over the namespace alias.
If this alias is the same as an existing namespace, you can use ":" to try the alias, which limits the alias namespace to be called.
using MyNamespace = ConsoleApplication19Namespace.MyNamespace2;namespace ConsoleApplication19Namespace{ class Program { static void Main(string[] args) { MyNamespace.Myclass My = new MyNamespace.Myclass(); My.print(); MyNamespace::Myclass You = new MyNamespace::Myclass(); You.print(); } } namespace MyNamespace { class Myclass { public void print() { Console.WriteLine("This is in the ConsoleApplication.MyNamespace.Myclass"); } } } namespace MyNamespace2 { class Myclass { public void print() { Console.WriteLine("This is in the ConsoleApplication.MyNamespace2.Myclass"); } } }}
Output:
This is in the ConsoleApplication. MyNamespace. Myclass
This is in the ConsoleApplication. MyNamespace2.Myclass
<2> global namespace
Global and ":" use the alias of the top-level root namespace together with globale:. Calling the top-level root namespace can prevent external variables or external classes from being internal variables, the appearance of hidden internal classes.
For example:
Global: System. Console. WriteLine ("what a fuck day"); // No problem occurs.