The tutorial for today will cover the use of Nuget Package Manager with a known package named NBitcoin.
First, open your Visual Studio and create a console project for C#.
I used Visual Studio version 2019 for this project.
In the right area, you have the Solution Explorer with your project tree list.
Select the item Dependencies from the tree list and using the right-click select Manage NuGet Packages…
This will open on the left side of the Nuget Package Manager where you can install the packages.
I install the NBitcoin version 5.0.40, see the next screenshot:
This package allows you to use Bitcoin features, see the GitHub project:
NBitcoin is the most complete Bitcoin library for the .NET platform. It implements all the most relevant Bitcoin Improvement Proposals (BIPs). It also provides low-level access to Bitcoin primitives so you can easily build your application on top of it. Join us in our gitter chat room. It works on Windows, Mac, and Linux with Xamarin, Unity, .NET Core, or CLR. (Porting to Unity should not be that hard if you need it)
The next source code show you how can use this package to generate a pubic key, hash, address, and script.
static void Main(string args)
Console.WriteLine("This is an example for Bitcoin using!");
Key key = new Key();
PubKey pubkey = key.PubKey;
Console.WriteLine("Public key: " + pubkey);
KeyId hash = pubkey.Hash;
Console.WriteLine("Hash public key: " + hash);
BitcoinAddress address = pubkey.GetAddress(Network.Main);
Console.WriteLine("Address: " + address);
Script scriptPubKey = address.ScriptPubKey;
Console.WriteLine("Script: " + scriptPubKey);