C# Set default namespace when conflicted

Is it possible to set a default namespace for the compiler to look at when you have a conflict between two namespaces?

My problem comes from using iTextSharp in a C# ASP.NET application. I'm adding the iTextSharp library to a page but this library conflicts a few items with the standard System WebControls library.

I know I can fully qualify each class reference to resolve the conflict and I know I can alias the namespaces to save myself using the full qualifications everywhere.

I'm wondering if it is possible to alias one namespace (iTextSharp) and default all references in my code to the unaliased namespace (WebControls)?

So for example if I aliased iTextSharp as "text":

ListItem l = new ListItem();

would reference Webcontrols but

text.ListItem l = new text.ListItem();

would reference iTextSharp.

I ask as there are a whole bunch of webcontrols on the page, and I don't particularly want to go through all the code and qualify each and every one of them.

Thanks in advance for any responses.

Jon Skeet
people
quotationmark

Well not quite like that, but you could use a namespace alias directive:

using System.Web.UI.WebControls;
using text = iTextSharp;
...

text::ListItem l = new text::ListItem();

You'd then not want a straight using directive for iTextSharp, as that would make just ListItem ambiguous again.

people

See more on this question at Stackoverflow