tags:

views:

458

answers:

3

I Have seen double colons in generated code , I was wondering what its purpose is?

A: 

It is the scope resolution operator:

http://en.wikipedia.org/wiki/Scope_resolution_operator

The scope resolution operator (::) in C++ is used to define the already declared member functions (in the header file with the .hpp or the .h extension) of the class

Mr-sk
This is a decent enough answer, but the questions related to C#, not C++ as the quote indicates. Luckily the use of the operator is pretty much the same between languages
mjmarsh
It's not really "pretty much the same": in C++ it's for defining member functions outside the class declaration, in C# it's for disambiguating type names.
itowlson
According to MSDN(http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.80%29.aspx), the scope resolution operator for C# is . not ::
Ferruccio
This isn't actually the correct answer for C#.Mark Byers, below, got it right.
Rob Levine
OH snap - sorry, too fast on the read/post.
Mr-sk
+30  A: 

It's the namespace alias qualifier operator.

The namespace alias qualifier (::) is used to look up identifiers. It is always positioned between two identifiers, as in this example:

global::System.Console.WriteLine("Hello World");
Mark Byers
+11  A: 

This is the namespace alias qualifier. It's used when there's the potential for two different types with the same name and same namespace (coming from different assemblies). E.g. our ORM product talks to VistaDB 3 and VistaDB 4. In both cases the connection class is VistaDB.Provider.VistaDBConnection. So we extern alias the VistaDB 3 assembly to vdb3 and the VistaDB 4 assembly to vdb4 and can now disambiguate the connection classes as vdb3::VistaDB.Provider.VistaDBConnection and vdb4::VistaDB.Provider.VistaDBConnection. Without the alias qualifier, these would raise "ambiguous reference" compiler errors.

itowlson