我正在开发一个项目,该项目应该将 Yahoo Weather API 与 ASP.Net MVC 3 连接起来。创建变量后,它给了我一个名为“找不到类型或命名空间名称‘WeatherForecast’的错误(您是否缺少使用指令还是程序集引用?)C:\Users\kumi.SH\Documents\Learn\ASP.Net_MVC3\WeatherApp\WeatherApp\Controllers\HomeController.cs"
我的 HomeController.cs 文件中有以下代码:
public ActionResult GetWeather(string Id)
{
StringBuilder sb = new StringBuilder();
WeatherForecast wf = new WeatherForecast();
WeatherForecasts wfs = wf.GetWeatherByPlaceName(Id);
WeatherData[] wd = wfs.Details;
sb.AppendFormat("<B>Weather Forecast for {0}</B><br /><br />", wfs.PlaceName);
foreach (WeatherData d in wd)
{
if (!string.IsNullOrEmpty(d.WeatherImage))
{
sb.AppendFormat("<img src=\"{0}\" >", d.WeatherImage);
sb.AppendFormat(" {0}", d.Day);
sb.AppendFormat(", High {0}F", d.MaxTemperatureF);
sb.AppendFormat(", Low {0}F<br />", d.MinTemperatureF);
}
}
Response.Write(sb.ToString());
return null;
}
您能否指定需要使用的命名空间?
提前谢谢......