简体   繁体   English

如何消除对名称空间前缀的需要?

[英]How to remove the need for a namespace prefix?

I've written a class... 我写了一堂课

namespace SharpQuery
{
    public static class SharpQuery
    {
        public static IEnumerable<HtmlNode> Load(Uri uri)
        {
            // ...

But when I want to call the Load method from inside a different namespace I have to write SharpQuery.SharpQuery.Load even if I put using SharpQuery; 但是,当我要调用的Load从一个不同的命名空间我必须写内部方法SharpQuery.SharpQuery.Load即使我把using SharpQuery; at the top. 在顶部。 Why is that? 这是为什么? How do I get rid of the need to specify the namespace? 如何摆脱对指定名称空间的需求?

Eric Lippert wrote a series of blog posts saying that you shouldn't have namespaces and classes with the same names. 埃里克·利珀特(Eric Lippert)写了一系列博客文章,说您不应该具有名称相同的名称空间和类。 Links here: http://blogs.msdn.com/b/ericlippert/archive/tags/namespaces 此处的链接: http : //blogs.msdn.com/b/ericlippert/archive/tags/namespaces

He explains it much better than I could. 他解释得比我好得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM