Traditional Culture Encyclopedia - Weather forecast - How to write a weather forecast software with C#

How to write a weather forecast software with C#

I once wrote one with a console application. Let me give you an idea.

Click References to add a service reference. At the bottom of the pop-up box, click Advanced, and then click Add Web Reference in the next interface. Add a Web reference pops up, write the following link in the url: /WebServices/WeatherWS.asmx, and then click the arrow next to it.

After success, define a name (for example, My Weather) in the Web reference name on the right; Next, click the Add Reference button to be ok;

Static electricity Invalid? Main(string[]? Parameter)

{

My weather. WeatherWS? ms? =? New? My weather. weather ws();

string[]? Dear? =? ms . getregionprovince(); ? //This method gets all provinces. You can annotate the following code and write a foreach traversal to see the effect.

String? ProvinceId=pro[5]。 Substring(pro[5].IndexOf(","+ 1); //This is used to get the ID of a province. How about five o'clock? That is, the index of Henan is 5, because the output form is? Province, province id, so it is ok to use indexof () to get the province id.

string[]? City? =? ms . getsupportcitystring(province id); //Similarly, use the id of a province to get all its cities.

String? CityId? =? City [36]. Substring (city[5].IndexOf (",")? +? 1); ? //Also get the ID of a city;

String? []? Result =? Ms. getWeather (ProvinceId, city id); ? //This is a one-dimensional array of weather conditions returned, so it's ok to process the next one. Parameters are province id and city id;

Console. ReadLine();

}

This is a common code. It's ok if you can change it. I hope it helps you.