using System.Collections.Generic;
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync("https://randomuser.me/api?results=10");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
RootObject root = JsonSerializer.Deserialize<RootObject>(responseBody);
Console.WriteLine($"Result count: {root.results.Count()}");
foreach(var item in root.results)
Console.WriteLine($"{item.name.first} {item.name.last}");
var averageAge = root.results.Average(x=> x.dob.age);
Console.WriteLine($"Average Age: {averageAge}");
public List<Result> results { get; set; }
public Info info { get; set; }
public string gender { get; set; }
public Name name { get; set; }
public string email { get; set; }
public Dob dob { get; set; }
public string phone { get; set; }
public string cell { get; set; }
public Id id { get; set; }
public string nat { get; set; }
public string title { get; set; }
public string first { get; set; }
public string last { get; set; }
public string name { get; set; }
public string value { get; set; }
public DateTime date { get; set; }
public int age { get; set; }
public string seed { get; set; }
public int results { get; set; }
public int page { get; set; }
public string version { get; set; }