What is the "global ::" in C #?

9

I've been editing a source code for an application I'm writing in C #, which uses GTK +.

I have some knowledge of C #, but I did not understand why some variables were written when I mounted the UI in the "drag and drop" with global:: before the names.

See the snippet of code:

private Gtk.VBox vbox2;

private global::Gtk.VBox vbox3;

private global::Gtk.Label tituloLogin;

private global::Gtk.Entry entry1;

private global::Gtk.Entry entry2;

What is this global:: worth? What does it mean?

    
asked by anonymous 15.03.2017 / 18:50

1 answer

9

global:: references the global namespace. For example, you can reset the class System , look:

class foo
{
    class System
    {

    }    
}

Then, for example, if you want to use Console.WriteLine() in that scope, without conflict, you use:

global::System.Console.WriteLine("teste");

I based my answer on this here .

    
15.03.2017 / 18:55