Exactly as the title says, I think I was looking at c# code when I saw this a while back, I never took much notice of it, but what does :: Mean in c#. I think I saw something like myVar::Process.Start()
3 Answers
It is the namespace alias qualifier - if you use namespace aliases:
using config = System.Configuration;
...
var value = config::ConfigurationManager.AppSettings["Somthing"];
It helps disambiguating when you have types with the same name in the same scope.
For example - if you have several Leg classes (one for furniture, one for the leg of a journey), and both are in imported namespaces, with the result that when you use Leg in your code the compiler can't tell which one you mean, then if you have a namespace aliases to the namespaces, you can use <alias>::Leg to refer to the exact type you mean.
There is a default alias global for the global namespace.
It's in the docs:
The namespace alias qualifier (::) is used to look up identifiers. It is always placed between two identifiers, as in this example:
global::System.Console.WriteLine("Hello World");
How to: Use the Namespace Alias Qualifier(C# Programming Guide) is probably also useful.
You would use :: if you has a method or property named the same as another, in a lower namespace. For instance:
namespace Taylor
{
public Console {get; set;}
}
So let's say you wanted to use Console.WriteLine();
Without using the global::System.Console.WriteLine(); It is, by default, going to be using Taylor.Console simply because it is pointing to this
It basically makes it differentiate among namespaces, to one you specify; the most common being: global (the lowest level).
This example is a little redundant, as System.Console will point to it anyway. Viewing Oded's example sheds some light on how to use :: while also using it dynamically.