tags:

views:

482

answers:

2

How can I get C# to distinguish between ambiguous class types without having to specify the full 'HtmlAgilityPack.HtmlDocument' name every time (it is ambiguous compared to 'Systems.Windows.Forms.HtmlDocument'

Is there a way to make C# know that I am ALWAYS talking about one class or the other, and thus not have to specify each time I use it?

+15  A: 

Use aliases:

using HapHtmlDocument = HtmlAgilityPack.HtmlDocument;
using WfHtmlDocument = System.Windows.Forms.HtmlDocument;
Hosam Aly
Perfect! Thank you.
Alex Baranosky
+5  A: 

You can define an alias for one namespace, e.g:

using hap = HtmlAgilityPack;

and then use the alias instead of the full namespace:

hap.HtmlDocument doc = new hap.HtmlDocument;
M4N