How to qualify a global namespace like in C++ 
Author Message
 How to qualify a global namespace like in C++

You can use the "using alias"  to resolve  this.

using GSystem=System;
namespace ClassLibraryCSharp
{
  namespace System
  {
    public class Class1{}
  }
  public class Class2
  {
    System.Class1 C1;
    public Class2()
    {
     ClassLibraryCSharp.System.Class1 C1 = new System.Class1();    
     GSystem.Boolean b = false;    
    }
  }

Quote:
}

Thank you,
Bobby Mattappally
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Quote:
>If i want to create a namespace with the same name as a
>global one (System for exemple), i'm unable to use global
>one where mine is visible.

>namespace ClassLibraryCSharp
>{
>  namespace System
>  {
>    public class Class1{}
>  }
>  public class Class2
>  {
>    System.Class1 C1;
>    public Class2()
>    {
>      System.Class1 C1 = new System.Class1();
>      System.Boolean b = false; // Error! Compiler
>mesage : "The type or namespace name 'Boolean' does not
>exist in the class or namespace 'ClassLibrary.System' (are
>you missing an assembly reference?)"
>    }
>  }
>}

>In C++, to resolve ambiguity i can write "::" before
>  ::System::Boolean b = false;
>but how to do such think in C#?

>Olivier



Sat, 23 Oct 2004 08:37:49 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Qualifying global namespace

2. using qualified namespaces causes Error 2352

3. Renaming the global namespace

4. stupid me: LoadLibrary not in global namespace

5. friend global functions in namespace classes

6. Implementing Event Sink for ActiveX Automation Object in global namespace

7. Global namespace

8. CoInitializeEx and the global namespace...

9. Reuse of cs files, namespace, arch advice pls

10. Managed C++ wont include c# namespace (user defined)

11. Problems with C++ classes within a namespace

12. Managed C++ can't see System::Text::RegularExpressions namespace

 

 
Powered by phpBB® Forum Software