【问题标题】:C# Net Class referenced class library: why must I fully qualify a public class?C# Net Class 引用的类库:为什么我必须完全限定公共类?
【发布时间】:2014-02-07 10:36:23
【问题描述】:

有一个烦人的问题,虽然我已经构建了一个类并在客户端程序中引用它,如下所示 - 使用 using,编译器需要我的方法的完全限定名称。

// this doesn't compile because it does not recognize the Decrypt method
using PGPEncryptDecrypt.Helpers.PGP;

namespace TestComInterOpPGP
{
class Program
{
    static void Main(string[] args)
    {
         PGPEncryptDecrypt.Decrypt(@"C:\Users\blah.pgp",
            @"C:\Users\secring.gpg",
            "pwd",
            @"C:\Users\out.txt");

    }
}
}

必须完全符合条件

// this does compile
using PGPEncryptDecrypt.Helpers.PGP;

namespace TestComInterOpPGP
{
class Program
{
    static void Main(string[] args)
    {
         PGPEncryptDecrypt.Helpers.PGP.PGPEncryptDecrypt.Decrypt(@"C:\Users\blah.pgp",
            @"C:\Users\secring.gpg",
            "pwd",
            @"C:\Users\out.txt");

    }
}
}

【问题讨论】:

    标签: c# class namespaces naming fully-qualified-naming


    【解决方案1】:

    啊——在键入此内容时,我意识到问题在于 PGPEncryptDecrypt 类与命名空间的第一部分具有相同的名称。所以我只是改变了一个或另一个,不需要完全符合条件。也许这会对某人有所帮助!

    【讨论】:

      猜你喜欢
      • 2014-09-23
      • 1970-01-01
      • 2013-10-03
      • 2011-09-27
      • 2011-11-06
      • 2013-06-29
      • 2015-02-04
      • 1970-01-01
      • 2021-04-21
      相关资源
      最近更新 更多