Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C Sharp Programming/Keywords/global

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Keywords global __TOC__ The global keyword is useful in some contexts to resolve ambiguity between identifiers. If you have a conflict between a class name and a namespace, for example, you can use the global keyword to access the namespace: namespace MyApp { public static class System { public static void Main() { global::System.Console.WriteLine("Hello, World!"); // if we had just used System.Console.WriteLine, // the compile would think that we referred to a // class named "Console" inside our "System" class. } } } global does not work in the following situation, however, as our System class does not have a namespace: public static class System { public static void Main() { global::System.Console.WriteLine("Hello, World!"); // "System" doesn't have a namespace, so the above // would be referring to this class! } }