Proper use of global:: (or Global.)
June 8th, 2007 by Sameer | Filed under .NET articles.The C# keyword global:: (also known as Global.) allows .NET to differentiate between two namespaces.
Say you have a namespace called Common, and you have a class called Setup
In that case, to refer to a function inside it called GetUsersOnline(), you would write Common.Setup.GetUsersOnline()
However, say that you are currently working within the Accounting namespace, and the accounting namespace had a class called Common. If you tried to type Common.GetUsersOnline(), .NET would say,… hey! Accounting.Common exists, but there is no GetUsersOnline() in there.. So.. crash
So in order to help .NET solve this mystery, append global:: to the beginning of the namespace, and all will be fine.
global::Common.GetUsersOnline();
