Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In one code i saw construction with double point ::
Where is uses? Can you give me example.

Thank you. I learn much here with your answers!
Posted
Comments
Sergey Alexandrovich Kryukov 15-Apr-13 16:53pm    
Could you possibly stop spamming this forum with questions you should have answered by just reading a manual?
—SA
joshrduncan2012 15-Apr-13 16:57pm    
I agree with you. My +5.
Sergey Alexandrovich Kryukov 15-Apr-13 17:01pm    
Thank you, but I also decided to put some answer, please see.
Actually, it's time to report on the OP's account for abuse. I just saw other questions...
—SA
DinoRondelly 15-Apr-13 17:04pm    
Yes it is about time,
Richard C Bishop 15-Apr-13 16:57pm    
I second that notion. You have never accpeted anyones answers and given credit. Also, almost every one of your questions does not follow the posting rules.

There are no secrets or techniques we could share with you, this is just the part of syntax.

Please see:
http://www.cplusplus.com/doc/tutorial/namespaces/[^],
http://www.learncpp.com/cpp-tutorial/811-static-member-variables/[^].

You will find more than enough examples on those manual pages.

You should not even get to programming in you did not read about it. And you should not waste time on asking such questions. Imagine what can happen if everyone starts asking about using ';', "using", '->' and other things like that? This is just spam. You will learn what you need to learn much easier if you start reading the manual doing simple exercises as you go. Please do it and refrain from asking any questions until you do at least one pass. The sites referenced above are good enough.

—SA
 
Share this answer
 
v2
Comments
DinoRondelly 15-Apr-13 17:19pm    
Ya this is worth a 5,
Sergey Alexandrovich Kryukov 15-Apr-13 17:59pm    
Thank you, Dino.
—SA
There's no such operator is C#. In C++ on the other hand... You've already been given the resources to learn about it.
 
Share this answer
 
If two assemblies use exactly the same name for a type it should be obvious that it is going to impossible to use both types unless the compiler can uniquely identify each one. External aliases are used to resolve type name abiguities and :: is the separator for a namespace alias and the namespace member.

As a crazy example create an assembly named OtherSystem containing a type called System.String.
C#
namespace System {
  // Clashes with the built in System.String type
  public class String {
  }
}


Any attempt to use this type will almost certainly result in compilation failure and a message such as
The type 'System.String' exists in both 'OtherSystem.dll' and 'mscorlib.dll'


To fix this problem the OtherSystem assembly must be given an external alias when it is referenced by another project.

The external alias is defined on the C# compiler command line
csc /reference:MySystem=OtherSystem.dll ExternalAliasTest.cs

but may also be set within Visual Studio on the reference property sheet for OtherSystem.dll.

Source code wishing to refer to the alias must have a matching external alias directive to ensure that any type names prefixed with MySystem:: are resolved properly.

C#
// allow this code to use the external alias
extern alias MySystem;
using System;

namespace ExternalAliasTest {
  class Program {
    static void Main() {
      Console.WriteLine(typeof(System.String).AssemblyQualifiedName);
      Console.WriteLine(typeof(MySystem::System.String).AssemblyQualifiedName);
      Console.ReadLine();
    }
  }
}


The output of the program shows that we are able to access both System.String types.
System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.String, OtherSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null


Alan.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900