有一个烦人的问题,尽管我已经构建了一个类并在如下所示的客户端程序中引用了它 - 通过使用,编译器想要我的方法的完全限定名称。
// 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");
}
}
}
最佳答案
啊 - 在输入这个时我意识到问题是 PGPEncryptDecrypt 类与命名空间的第一部分具有相同的名称。所以我只是改变了其中一个,不需要完全合格。也许这会帮助某人!
关于C# Net Class 引用的类库 : why must I fully qualify a public class?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21197054/