我讀這段代碼sample:Base64ToHex()的代碼示例
而且因爲我不知道C#,我決定搏一搏。
在編譯時,我得到這個消息:
Main.cs(32,65): error CS1061: Type `string' does not contain a definition for `Base64ToHex' and no extension method `Base64ToHex' of type `string' could be found (are you missing a using directive or an assembly reference?)
Compilation failed: 1 error(s), 0 warnings
我在MSDN外觀和預期我沒有找到這種方法的參考。
問題:該方法從哪裏來的?
p.s.我的代碼如下所示:
using System.Security.Cryptography;
using System.Text;
using System;
class MainClass
{
public static string Encrypt(string toEncrypt, string key, bool useHashing)
{
..... // same as in post
.....
}
public static void Main(string [] args)
{
string key = "secret";
Console.WriteLine(Encrypt("oscar" + "000", key, true).Base64ToHex());
}
}
該方法調用是在你正在閱讀的東西的代碼中? – CSharpAtl 2009-05-20 18:16:29
他們可能會引用一個庫,他們編寫了一個名爲Base64ToHex()的擴展方法() – CSharpAtl 2009-05-20 18:17:01