做个天气预报的小例子
生活随笔
收集整理的這篇文章主要介紹了
做个天气预报的小例子
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
引用別人的WebServices
http://www.ayandy.com/
本服務數據來源于中國氣象局數據,實時更新,準確可靠,包括國內外400多個主要城市。請不要用于任何商業目的,若有需要請與作者聯系,歡迎技術交流。作者QQ:15244833 E-Mail:secretary@ayandy.com
The following operations are supported. For a formal definition, please review the Service Description.
- getSupportCity
查詢本天氣WebService支持的城市信息。輸入參數: byProvinceName 指定的省份,若為ALL則表示全部。返回數據:一個二維數組String[],String[0]為返回的個數。 - getSupportProvince
查詢本天氣WebService支持的省份信息。輸入參數: 無。 返回數據:一個二維數組String[],String[0]為返回的個數。 - getWeatherbyCityName
根據城市名稱獲得天氣情況。調用方法如下:輸入參數: theCityName 城市中文名稱,如深圳,北京; theDayFlag 指定是當天(1),明天(2)或后天(3),可查詢未來三天的天氣情況;返回數據: String[7] 一個一維數值,共有七個元素,從[1]到[6]分別表示城市,天氣,溫度,風向,日期,天氣圖標地址。
?
看下代碼
?
?
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Web.Services;using Fxrl.com.ayandy.www; namespace Fxrl{ public partial class WebService1 : Form { public WebService1() { InitializeComponent(); }? private void button1_Click(object sender, EventArgs e) { com.ayandy.www.Service obj = new Service();?? string[] a1 = new string[10]; try { a1 = obj.getWeatherbyCityName(textBox1.Text, com.ayandy.www.theDayFlagEnum.Today); label1.Text = a1[1].ToString(); label2.Text = a1[2].ToString(); label3.Text = a1[3].ToString(); label4.Text = a1[4].ToString(); label5.Text = a1[5].ToString(); pictureBox1.ImageLocation = a1[6].ToString(); } catch { } } }}
轉載于:https://www.cnblogs.com/zbqy/archive/2007/03/15/676005.html
總結
以上是生活随笔為你收集整理的做个天气预报的小例子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 简易的实现对象内存池
- 下一篇: 如何理解矩阵