I am retrieving some values into a combobox from API.
class grades
{
public string id { get; set; }
public string grade { get; set; }
}
class gradeHelper
{
public List<grades> result { get; set; }
}
This is the way I get the data and pass it to the list.
HttpClient httpClient = new HttpClient();
var content = await httpClient.GetStringAsync(new Uri(baseAddress));
gradeHelper result = JsonConvert.DeserializeObject<gradeHelper>(content);
foreach (var item in result.result)
{
cmbGrade.Items.Add(result);
}
The value that gets filed in my combobox is the path which is the solution name.folder name.class name
"ted.datamodel.gradehelper"
I think you did the things wrongly, what my view is
HttpClient httpClient = new HttpClient();
var content = await httpClient.GetStringAsync(new Uri(baseAddress));
gradeHelper data = JsonConvert.DeserializeObject<gradeHelper>(content);
foreach (var item in data.result)
{
cmbGrade.Items.Add(item.grade);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.