using System.Collections.Generic;
using System.Threading.Tasks;
public static async Task Main()
var countries = await new CountryDownloader().GetCountriesAsync("europe");
Console.WriteLine($"I downloaded {countries.Count()} countries.");
public class CountryDownloader
public async Task<IEnumerable<CountryInfo>> GetCountriesAsync(string region)
using (var client = new HttpClient())
var result = await client.GetStringAsync($"https://restcountries.eu/rest/v2/region/{region}");
return JsonConvert.DeserializeObject<IEnumerable<CountryInfo>>(result);
public string Name { get; set; }
public string Capital { get; set; }