如何通过C#来区分不明确的类名?
我怎样才能让C#区分不明确的类类型而不必每次都指定完整的HtmlAgilityPack.HtmlDocument
名称(与System.Windows.Forms.HtmlDocument
相比它是不明确的)?
有没有办法让C#知道我总是在谈论一个类或另一个类,因此每次使用它时都不必指定它?
使用别名:
using HapHtmlDocument = HtmlAgilityPack.HtmlDocument; using WfHtmlDocument = System.Windows.Forms.HtmlDocument;
您可以为一个名称空间定义别名,例如:
using hap = HtmlAgilityPack;
然后使用别名而不是完整的命名空间:
上述就是C#学习教程:如何通过C#来区分不明确的类名?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)
hap.HtmlDocument doc = new hap.HtmlDocument;
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请点击右边联系管理员删除。
如若转载,请注明出处:https://www.ctvol.com/cdevelopment/998822.html