In most cases, when there are namespace conflicts, developers tend to use the complete qualified name in the code. For example:
using System.Web.UI.WebControls;
using MyComponent.Web.UI.WebControls;
This is usually okay for simple class filesassuming that there is a Calendar class in both namespaces and you need to use the custom class in many sections of the class.
However, instead of specifying the fully qualified name, you could also give an alias for the namespace and make use of it everywhere, like this:
using System.Web.UI.WebControls;
using MyControls = MyComponent.Web.UI.WebControls;
Then, instead of using the fully-qualified name like this:
MyComponent.Web.UI.WebControls.Calender cal =
new MyComponent.Web.UI.WebControls.Calender();
You'd be able to use the shorter aliased name, like this:
MyControls.Calender cal = new MyControls.Calender();
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!
If you have a hot tip and we publish it, we'll pay you. However, due to accounting overhead we no longer pay $10 for a single tip submission. You must accumulate 10 acceptable tips to receive payment. Be sure to include a clear explanation of what the technique does and why it's useful. If it includes code, limit it to 20 lines if possible. Submit your tip here.