private static List <TriviaCategory> GetEntertainmentCategories(CategoryResponse catResponse) { //LINQ to Object //all entertainment categories sorted alphabetically return(catResponse.trivia_categories .Where(c => c.name.StartsWith("Entertainment")) .OrderBy(c => c.name) .ToList()); }
private async void Form1_Load(object sender, EventArgs e) { //Access the list of categoies from the Web API HttpResponseMessage response = await client.GetAsync("api_category.php"); if (response.IsSuccessStatusCode) { string cats = await response.Content.ReadAsStringAsync(); CategoryResponse catResponse = JsonConvert.DeserializeObject <CategoryResponse>(cats); List <TriviaCategory> entertainment = GetEntertainmentCategories(catResponse); PopulateCategoryComboBox(entertainment); } }