
C# 语言中如何在主函数中调用类Chapter1中的变量adress,急求答案,谢谢~
namespaceProgrammingBlockchain.Chapters{classChapter1{publicvoidLesson1(){Keykey=newK...
namespace ProgrammingBlockchain.Chapters
{
class Chapter1
{
public void Lesson1()
{
Key key = new Key(); //generates a new private key.
PubKey pubKey = key.PubKey; //gets the matching public key.
Console.WriteLine("Public Key: {0}", pubKey);
KeyId hash = pubKey.Hash; //gets a hash of the public key.
Console.WriteLine("Hashed public key: {0}", hash);
// 下面语句的adress是在主函数中需要提取的变量
BitcoinAddress address = pubKey.GetAddress(Network.Main); //retrieves the bitcoin address.
Console.WriteLine("Address: {0}", address);
Script scriptPubKeyFromAddress = address.ScriptPubKey;
Console.WriteLine("ScriptPubKey from address: {0}", scriptPubKeyFromAddress);
Script scriptPubKeyFromHash = hash.ScriptPubKey;
Console.WriteLine("ScriptPubKey from hash: {0}", scriptPubKeyFromHash);
}
}
} 展开
{
class Chapter1
{
public void Lesson1()
{
Key key = new Key(); //generates a new private key.
PubKey pubKey = key.PubKey; //gets the matching public key.
Console.WriteLine("Public Key: {0}", pubKey);
KeyId hash = pubKey.Hash; //gets a hash of the public key.
Console.WriteLine("Hashed public key: {0}", hash);
// 下面语句的adress是在主函数中需要提取的变量
BitcoinAddress address = pubKey.GetAddress(Network.Main); //retrieves the bitcoin address.
Console.WriteLine("Address: {0}", address);
Script scriptPubKeyFromAddress = address.ScriptPubKey;
Console.WriteLine("ScriptPubKey from address: {0}", scriptPubKeyFromAddress);
Script scriptPubKeyFromHash = hash.ScriptPubKey;
Console.WriteLine("ScriptPubKey from hash: {0}", scriptPubKeyFromHash);
}
}
} 展开
1个回答
2016-08-17
展开全部
Chapter1中,没有变量 address ,方法内的,不算 。 。。。。。。。。。。。。。。
追问
那应该怎么改呢?
在Chapter1中加入adress的定义吗?
追答
是否要添加,要看需求逻辑要求的。。。。。。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询