Get Current Bitcoin Price With A Few Lines of C#

C# example of retrieving the current price of Bitcoin using Coindesk’s REST API:

string json;

using (var web = new System.Net.WebClient())
{
var url = @"https://api.coindesk.com/v1/bpi/currentprice.json";
json = web.DownloadString(url);
}

dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
var currentPrice = Convert.ToDecimal(obj.bpi.USD.rate.Value);

Console.WriteLine(currentPrice);