Код: Выделить всё
public class Result1
{
public string Price { get; set; }
public string Id { get; set; }
}
public class Result2
{
public string firstName { get; set; }
public string lastName { get; set; }
public string Id { get; set; }
}
public class JsonResult1
{
public List
ProductLists { get; set; }
}
public class JsonResult2
{
public List UserLists { get; set; }
}
Код: Выделить всё
public async Task GetFirstMethod(string id, string a)
{
var info = JsonConvert.DeserializeObject(a);
var mylist = new List();
foreach (var item in info.ProductLists)
{
mylist.Add(new Result1()
{
Price = item.Price,
Id = item.ID
});
}
return mylist;
}
public async Task GetSecondMethod(string id, string a)
{
var info = JsonConvert.DeserializeObject(a);
var mylist = new List();
foreach (var item in info.UserLists)
{
mylist.Add(new Result2()
{
firstName = item.FirstName,
lastName = item.LastName,
Id = item.ID
});
}
return mylist;
}
//And the third method and the fourth method and...
Как создать общий метод для всех вышеперечисленных методов??
Основная проблема заключается в отображении части внутри списка...
Можно ли вообще сделать что-то подобное?
Подробнее здесь: https://stackoverflow.com/questions/787 ... ric-method