fork download
  1. public class Api
  2. {
  3. public const string apiUrl = "http://j...content-available-to-author-only...e.com/photos";
  4.  
  5. public async Task<IEnumerable<Photo>> GetPhotosAsync()
  6. {
  7. using HttpClient http = new HttpClient();
  8. using var response = await http.GetAsync(apiUrl);
  9. if(response.IsSuccessStatusCode)
  10. {
  11. string json = await response.Content.ReadAsStringAsync();
  12. return JsonConvert.DeserializeObject<IEnumerable<Photo>>(json);
  13. }
  14. return Array.Empty<Photo>();
  15. }
  16.  
  17. }
  18.  
  19. public class Photo
  20. {
  21. public int AlbumId { get; set; }
  22. public int Id { get; set; }
  23. public string Title { get; set; }
  24. public string Url { get; set; }
  25. public string ThumbnailUrl { get; set; }
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(7,18): error CS1525: Unexpected symbol `HttpClient', expecting `('
prog.cs(8,18): error CS1525: Unexpected symbol `var', expecting `('
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty