C#调用REST API

本文介绍了一道上机测试题,题目要求使用C#开发一个Windows窗体应用,通过REST API获取未来三天某城市的最高、最低和平均温度。应用包含城市输入框、温度单位选择组合框,并使用免费的WorldWeatherOnline API。要求使用LINQ计算温度,保持UI响应,以及错误处理。代码实现了在请求数据时显示状态提示,并在数据获取后更新状态。
摘要由CSDN通过智能技术生成

由于辞职的原因,最近正在忙于找工作。在这段期间收到了一家公司的上机测试题,一共两道题,其中一道题是关于REST API的应用。

什么是REST? 在此不详说。我说一下自己的理解吧。简单地说,REST就是一种基于HTTP请求服务从而达到操作资源的技术,其支持多种数据格式,比如xml、Json、Csv等等。Web Service是基本XML并利用SOAP协议实现远程资源访问操作的技术。因此,两者本质还是不同的。也许我的理解不完全正确,欢迎指出错误。

下面来看看这道题,如下:

Userstory:
As a user I want to be able to see maximum, minimum and average predicted temperature for the following 3 days,
based on the city that needs to be entered.
Acceptance criteria:
Windows form application written in C#
One input field to define the city
A combobox to select Fahrenheit or Celcius degrees
Use free web service provided by http://www.worldweatheronline.com
The following key can be used to retrieve data : c6bbde7c9c021451123107
Show 'Retrieving weather data...' in status bar when request of data is submitted. Once data is retrieved
update status accordingly.
Use of linq statements to calculate the minimum, maximum and average temperature.
Main form needs to be responsive at all times
Use of delegates
Retrieval of data and UI logic needs to be seperated in code
Error handling when connection

 

 

以下是我写的代码:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值