.NET C# 添加天气信息,…
2015-09-09 16:17
591 查看
1添加服务引用http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
2在视图中添加 WeatherWebServiceSoapClient w = new
WeatherWebServiceSoapClien("WeatherWebServiceSoap");
string[] s =
new string[23];//声明string数组存放返回结果
string city
= "绵阳";
s =
w.getWeatherbyCityName(city);
//以文本框内容为变量实现方法getWeatherbyCityName
if (s[8] ==
"")
{
ViewData["a"] = "暂时不支持您查询的城市";
}
else
{
//pictureBox1.Image = Image.FromFile(@"d:\image" + s[8] +
"");
ViewData["a"] = s[1] + " " + s[6];
ViewData["b"] = s[10];
}
3显示的地方添加@ViewData["a"]或者@ViewData["b"]
效果如图:
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
由于这个接口每天有使用限制,我们可以把拿到的数据存到数据库,再从数据库中取,就OK了
2在视图中添加 WeatherWebServiceSoapClient w = new
WeatherWebServiceSoapClien("WeatherWebServiceSoap");
string[] s =
new string[23];//声明string数组存放返回结果
string city
= "绵阳";
s =
w.getWeatherbyCityName(city);
//以文本框内容为变量实现方法getWeatherbyCityName
if (s[8] ==
"")
{
ViewData["a"] = "暂时不支持您查询的城市";
}
else
{
//pictureBox1.Image = Image.FromFile(@"d:\image" + s[8] +
"");
ViewData["a"] = s[1] + " " + s[6];
ViewData["b"] = s[10];
}
3显示的地方添加@ViewData["a"]或者@ViewData["b"]
效果如图:
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
![](http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif)
由于这个接口每天有使用限制,我们可以把拿到的数据存到数据库,再从数据库中取,就OK了
相关文章推荐
- C#:struct的陷阱:无法修改“xxx”的返回值,因为它不是变量
- C#打印螺旋数组
- 记c#中构造函数中this的用法
- C#互斥体——Mutex
- C#中的变量类型
- c#枚举遍历(转换)
- C#版 Socket编程(最简单的Socket通信功能)
- 学习C#修饰符:类修饰符和成员修饰符
- 解决VS2012 WPF中“对类型“ ”的构造函数执行符合制定的绑定约束的调用时引发了异常。行号为“3”,行位置为“9””问题的过程
- C# Mutex对象的使用
- C#WebBrowser控件使用教程与技巧收集
- c#对于mutex互斥量的深入理解
- 刚刚接触C#
- c#中的delegate(委托)和event(事件)
- C#中命名空间别名的使用
- C#中virtual, override, new的使用
- C#中Dictionary的用法
- C# 图片超过指定大小将压缩到指定大小不失真
- c#中抽象类和接口的相同点跟区别
- C#委托和事件