In fact, sometimes make some mistakes, is the class name to take a similar to the system class name, in fact, this is a design error, but there will be a situation is not changed, then the Global keyword has played a role.
The following code:
The code is as follows |
Copy Code |
Using System; using System.Collections.Generic; using System.Linq; using System.Text; Namespace Globalfunc { class program { static void Main (string[] args) { & nbsp; System sys = new system (); global::system.console.writeline ("Global ."); Global::system.console.readkey (); } } public class System {} } |
Although a System namespace is using, there is also a public class system{...} class, so that if you use System.Console.WriteLine directly, you will get an error, because you will find the nearest system class, there is no Console in the system class. So if you need to use it, you need to use Global::system.console.writeline as above, because classes that use the global tag start looking globally, and my understanding is to look inside the System class from the outermost.