+ 2
What does the keyword "global" in C#?
I have this question, what does?
1 Antwort
+ 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