+ 2

What does the keyword "global" in C#?

I have this question, what does?

12th Mar 2018, 7:29 PM
SebGM2018
SebGM2018 - avatar
1 Answer
+ 11
'global::' is used to access the global namespace instead of local. Suppose you have 2 scopes, the global and another local inside it and they both had a variable called 'a'. to access the global variable 'a' from inside the global namespace you just refer to it normally, but in order to access that variable from within a local scope that redefines the specific variable name ('a') you must refer to it as global::a otherwise the local 'a' will be used instead... https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/global
12th Mar 2018, 8:05 PM
Valen.H. ~
Valen.H. ~ - avatar