The global keyword is literally meant to be the whole world.
In fact, some times will make some mistakes, that is, the class name takes a similar to the system class name situation, in fact, this is a design error, but there will be a situation is not changed, then the global Key has played a role.
The following code:
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
6 namespace Globalfunc
7 {
8 Class Program
9 {
Ten static void Main (string[] args)
Each {
System sys = new system ();
global::system.console.writeline ("global");
Global::system.console.readkey ();
}
+ }
Public class System {}
18}
While using a System namespace, there is also a public class system{...} class, so that if the direct use of System.Console.WriteLine will be an error, because you will find the nearest system class, then there is no Console in this system class. So if you need to use it, you need to use Global::system.console.writeline, as above, because the class using the global tag will start looking at the world, and my understanding is to look for the System class from the outermost to the inside.
The Global keyword in C #