Tenho um aplicativo em Windows Forms de Clima/Tempo
Quero puxar os dados da Descriçao dentro da Classe Weather
public class weather
{
public string descrição { get; set; }
}
void getWeather(string city)
{
using (WebClient web = new WebClient())
{
string url = string.Format("http://api.openweathermap.org/data/2.5/weather?q={0}&appid={1}&units=metric&cnt==6", city, APPID);
var json = web.DownloadString(url);
var result = JsonConvert.DeserializeObject<weatherInfo.root>(json);
weatherInfo.root outPut = result;
txtCidade.Text = string.Format("{0}", outPut.name);
txtdescricao.Text = string.Format("{0}", outPut.sys.country);
txtTemp.Text = string.Format("{0} \u00B0" + "C", outPut.main.temp);
txtSensacao.Text = string.Format("{0} \u00B0" + "C", outPut.main.feels_like);
txtHumidity.Text = string.Format("{0}" + "%", outPut.main.humidity);
txtdescricao.Text = string.Format("{0}" + "%", outPut.weather.descricao);// O erro ocorre aqui, mas porque?
}
}
class weatherInfo
{
public class coord
{
public double lon { get; set; }
public double lat { get; set; }
}
public class weather
{
public int id { get; set; }
public string descrição { get; set; }
public string main { get; set; }
}
public class main
{
public double temp { get; set; }
public double pressure { get; set; }
public double humidity { get; set; }
public double feels_like { get; set; }
public double temp_min { get; set; }
}
public class wind
{
public double speed { get; set; }
}
public class sys
{
public string country { get; set; }
}
public class root
{
public string name { get; set; }
public sys sys { get; set; }
public double dt { get; set; }
public wind wind { get; set; }
public main main { get; set; }
public List<weather> weather { get; set; }
public coord coord { get; set; }
}
}
Só que ele me retorna esse Erro
CS1061 ‘List<weatherInfo.weather>’ não contém uma definição para "descricao" e não foi possível encontrar nenhum método de extensão "descricao" que aceite um primeiro argumento do tipo ‘List<weatherInfo.weather>’
Ja tentei:
txtdescricao.Text = string.Format("{0}" + "%", outPut.weather);
txtdescricao.Text = string.Format("{1}", outPut.weather);
Como eu consigo retornar os Resultados
public int id { get; set; }
public string descrição { get; set; }
public string main { get; set; }
Para uma Label?
outPut.weather[0].descrição)
weather
ou tem somente um?