一个可靠的天气预报Web Server

介绍了一个可靠的天气预报Web服务,可根据城市名称获取当前及未来三天的天气情况,包括天气状况、温度范围、风向等信息。提供了C#示例代码演示如何调用此服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一个可靠的天气预报Web Server:http://www.ayandy.com/getWeatherbyCityName 根据城市名称获得天气情况。本服务数据来源于中国气象局数据,实时更新,准确可靠。调用方法如下:输入参数: theCityName 城市中文名称,如深圳,北京; theDayFlag 指定是当天(1),明天(2)或后天(3),可查询未来三天的天气情况;返回数据: String[7] 一个一维数值,共有七个元素,从[1]到[6]分别表示城市,天气,温度,风向,日期,天气图标地址。
C#代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] cs;
            cs = new com.ayandy.www.Service().getSupportProvince();
            Int16   length;
            length = Convert.ToInt16(cs[0]);

            for (int i = 1; i <= length; i++)
                this.comboBox1.Items.Add( cs[i]);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] result = new com.ayandy.www.Service().getWeatherbyCityName(this.comboBox2.Text,com.ayandy.www.theDayFlagEnum.Today );

            MessageBox.Show(result[1] + "/" + result[2] + "/" + result[3]);


        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[] city;


            Int16 length;

            city = new com.ayandy.www.Service().getSupportCity(this.comboBox1.Text);
            length = Convert.ToInt16(city[0]);

            for (int i = 1; i <= length; i++)
                this.comboBox2.Items.Add(city[i]);


        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值