What does the keyword "global" in C#? | SoloLearn: Learn to code for FREE!

+2

What does the keyword "global" in C#?

I have this question, what does?

3/12/2018 7:29:21 PM

SebGM2018

1 Answer

New 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