Is System a reserved namespace in any combination?

I was creating a class with a namespace like this : MyCompany.System.MyLibrary. When I tried to use code from namespaces like System.Data in the same class the compiler could not find System.Data.

Is System a reserved namespace regardless of where it appears in a developers namespace?

2 Comments

  • use a using statement at the top of your code to alias your namespace.



    using x = MyCompany.System.MyLibrary;



    then you can use "x" to refer to your namespace:



    x.WhatEver y = new x.WhatEver();

  • In C# 2.0, they're introducing a new global:: operator which will fix this problem. At the moment, I'm pretty sure the only way around it is to put a:



    using System.Data;



    at the top and reference the types in their unqualified form. Or, don't use System in your own namespaces :-)

Comments have been disabled for this content.