Nethereum C#如何在地址中取得余额?

Nethereum C#如何在地址中取得余额?,c#,ethereum,C#,Ethereum,我试图在地址上取得平衡。 这是我的代码: `using System; using System.Collections.Generic; using System.Linq; using System.Text; using Nethereum.Web3; using System.Threading.Tasks; namespace ConsoleApp1 { class Program {

我试图在地址上取得平衡。 这是我的代码:

`using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Nethereum.Web3;
    using System.Threading.Tasks;

    namespace ConsoleApp1
    {
        class Program
        {

            static void Main(string[] args)
            {
                 Bananas().Wait();
            }

            static private async Task Bananas()
            {
                var publicKey = "0xC0b4ec83028307053Fbe8d00ba4372384fe4b52B";
                var web3 = new Nethereum.Web3.Web3("https://ropsten.infura.io/myInfura");
                //var txCount = await web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(publicKey);
                var balance = await web3.Eth.GetBalance.SendRequestAsync(publicKey);
                var etherAmount = Web3.Convert.FromWei(balance.Value);

                Console.WriteLine(web3);
                Console.WriteLine("Get txCount ", etherAmount);
                Console.ReadLine();
            }
        }
    }`
我通过PM控制台安装了Nethereum:。 我使用infura的正常链接。 为什么没有地址上的余额我不能得到下一个结果?

我刚刚用您的代码制作了一个控制台应用程序,所有数据都可以从Nethereum正常返回

您的问题在于
控制台。WriteLine(…
您正在将
etherAmount
作为
arg0
属性传递到
控制台。WriteLine运行时将无法在控制台上正确输出

试试这个

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Nethereum.Web3;
    using System.Threading.Tasks;

    namespace ConsoleApp1
    {
        class Program
        {

            static void Main(string[] args)
            {
                 Bananas().Wait();
            }

            static private async Task Bananas()
            {
                var publicKey = "0xC0b4ec83028307053Fbe8d00ba4372384fe4b52B";
                var web3 = new Nethereum.Web3.Web3("https://ropsten.infura.io/myInfura");
                //var txCount = await web3.Eth.Transactions.GetTransactionCount.SendRequestAsync(publicKey);
                var balance = await web3.Eth.GetBalance.SendRequestAsync(publicKey);
                var etherAmount = Web3.Convert.FromWei(balance.Value);

                Console.WriteLine(web3);
                Console.WriteLine("Get txCount " + etherAmount);
                Console.ReadLine();
            }
        }
    }

ps nice 1110.337873197299357846 ETH;)(我知道这只是测试ETH,但我们可以做梦)

另一个问题:如果我想用c#async向500人(比如说)发送以太,我如何使用TPL而不必等待每个发送完成(假设事务以不断增加的nonce发生)?谢谢,我之前用JavaScrit做过,我也想知道c#。非常感谢。您不必等待事务哈希。如果需要,您可以计算以获得事务哈希。