Solved

C# namespace conflict ?

Posted on 2002-04-19
1
1,562 Views
Last Modified: 2007-12-19
Is it possible to reference to environments' System namespace if project contains MyOwn.System namespace ?

below is simple example, there the Array class is not found, since only thing it founds from System. is the Sub class...

----
using System;

namespace MyOwn.System
{
  public class Sub
  {
    const int Number = 5;
  }
}

namespace MyOwn
{    
  public class Sub2
  {
    public Sub2()
    {
      System.Array a;   // Array is not found in System
    }
  }
}
0
Comment
Question by:TMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
CJ_S earned 158 total points
ID: 6957634
You can use the system namespace but you need to adjust your using statement to give the system namespace an alias.

using RealSystem = System;

And I suggest nesting. both together will solve your problem.

using RealSystem = System;

namespace MyOwn
{    
 public class Sub2
 {
   public Sub2()
   {
     RealSystem.Array a;   // Array is not found in System
   }
 }

 namespace System
 {
  public class Sub
  {
    const int Number = 5;
  }
}

}
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question