我读这段代码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