Вывести поля класса - C#
Формулировка задачи:
Листинг программы
- public class RootObject
- {
- public int code { get; set; }
- public string lang { get; set; }
- public List<string> text { get; set; }
- }
Решение задачи: «Вывести поля класса»
textual
Листинг программы
- public class Counters
- {
- public int albums { get; set; }
- public int videos { get; set; }
- public int audios { get; set; }
- public int notes { get; set; }
- public int photos { get; set; }
- public int groups { get; set; }
- public int gifts { get; set; }
- public int friends { get; set; }
- public int online_friends { get; set; }
- public int mutual_friends { get; set; }
- public int user_videos { get; set; }
- public int followers { get; set; }
- public int subscriptions { get; set; }
- public int pages { get; set; }
- }
- public class Response
- {
- public int id { get; set; }
- public string first_name { get; set; }
- public string last_name { get; set; }
- public Counters counters { get; set; }
- }
- public class RootObject
- {
- public List<Response> response { get; set; }
- }
- ...
- string textper;
- HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("https://api.vk.com/method/users.get?user_ids=171100325&fields=counters&v=5.60");
- HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
- using (StreamReader stream = new StreamReader(resp.GetResponseStream() , Encoding.UTF8))
- {
- textper= stream.ReadToEnd();
- }
- string responseText = textper;
- Counters response = JsonConvert.DeserializeObject <Counters> (responseText);
- Console.WriteLine(responseText);
- Console.WriteLine(response.albums); //почему-то выводит 0, а должно быть 2
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д