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 System.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 it each time I use it?
Use aliases:
using HapHtmlDocument = HtmlAgilityPack.HtmlDocument;
using WfHtmlDocument = System.Windows.Forms.HtmlDocument;
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With