2014-01-17 28 views
1

儘管我已經構建了一個類並在下面的客戶端程序中引用了它,但使用時卻遇到了令人討厭的問題,編譯器需要我的方法的完全限定名。C#Net類引用類庫:爲什麼我必須完全限定一個公共類?

// 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"); 

    } 
} 
} 

回答

2

啊 - 雖然打字我意識到問題是,類PGPEncryptDecrypt有同樣的名字作爲命名空間的第一部分。所以我只是改變了一個或另一個,並不需要完全符合條件。也許這會幫助別人!

相關問題