0

I added a Linq to SQL data access class to my project and dragged a table to the design surface and I looked at the code generated in the .cs file. I am trying to understand this snippet:

[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="AdventureWorks2008R2")]
public partial class AdventureWorksDataContext : System.Data.Linq.DataContext
{
    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

I think I understand attributes in a general way and even in this specific case but my real question is "What is meant by the double colon syntax?" Is the above attribute a "global attribute" as discussed elsewhere (for example, here at http://www.switchonthecode.com/tutorials/creating-and-reading-global-attributes-in-csharp1 )

A corollary question would be how to search for the meaning of the :: syntax in Google and/or within StackOverflow? I've tried placing it within quotes and ended up posting this.

John Adams
  • 4,773
  • 25
  • 91
  • 131

1 Answers1

2

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");

The namespace alias qualifier can be global. This invokes a lookup in the global namespace, rather than an aliased namespace.

http://msdn.microsoft.com/en-us/library/htccxtad.aspx
http://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
sanjosep43
  • 597
  • 5
  • 15
  • Just-a-link answers are discouraged on SO. Much better to provide a small abstract or quote the most relevant part here (in addition to the link). Assume the link goes dead after some time. – H H Sep 07 '12 at 20:16
  • Good point. Also, what about this related item (quoted from above)? "how to search for the meaning of the :: syntax in Google and/or within StackOverflow?" – John Adams Sep 07 '12 at 20:25