473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Conversion error

Hi,

Could some one help me with a conversion error I'm receiving. I'm trying to get the weather using webserviceX.net and I get the following error when I try to compile. By the way this is a ASP.NET 2.0 app.

Cannot implicitly convert type 'net.webservicex.www.WeatherData[]' to 'net.webservicex.www.WeatherData'

Here is the code I'm using.
Expand|Select|Wrap|Line Numbers
  1. net.webservicex.www.WeatherForecast forcast = new net.webservicex.www.WeatherForecast();
  2.         net.webservicex.www.WeatherForecasts forcasts = new net.webservicex.www.WeatherForecasts();
  3.         net.webservicex.www.WeatherData data = new net.webservicex.www.WeatherData();
  4.  
  5.         forcasts = forcast.GetWeatherByZipCode("07747");
  6.         data = forcasts.Details;
  7.  
  8.         TextBox1.Text = data.ToString();
  9.  
I would greatly appreciate it if someone could please help me resolve this.

Thank you.
May 24 '07 #1
3 1136
Frinavale
9,735 Expert Mod 8TB
Hi,

Could some one help me with a conversion error I'm receiving. I'm trying to get the weather using webserviceX.net and I get the following error when I try to compile. By the way this is a ASP.NET 2.0 app.

Cannot implicitly convert type 'net.webservicex.www.WeatherData[]' to 'net.webservicex.www.WeatherData'

Here is the code I'm using.
Expand|Select|Wrap|Line Numbers
  1. net.webservicex.www.WeatherForecast forcast = new net.webservicex.www.WeatherForecast();
  2.         net.webservicex.www.WeatherForecasts forcasts = new net.webservicex.www.WeatherForecasts();
  3.         net.webservicex.www.WeatherData data = new net.webservicex.www.WeatherData();
  4.  
  5.         forcasts = forcast.GetWeatherByZipCode("07747");
  6.         data = forcasts.Details;
  7.  
  8.         TextBox1.Text = data.ToString();
  9.  
I would greatly appreciate it if someone could please help me resolve this.

Thank you.
(Please use the code tags)

Line 1 you are creating a variable (forcasts) to hold a single forcast.
You need to declare forcasts as an array instead so that you can retrieve the array of forcasts returned by the GetWeatherByZipCode function on Line 5.


-Frinny
May 24 '07 #2
(Please use the code tags)

Line 1 you are creating a variable (forcasts) to hold a single forcast.
You need to declare forcasts as an array instead so that you can retrieve the array of forcasts returned by the GetWeatherByZipCode function on Line 5.


-Frinny
Thanks for the reply and sorry about the code I realized it after I had already clicked submit.

Can you please provide an example. If I make forcasts an array I won't be able to access the web method 'Details'.
May 24 '07 #3
Frinavale
9,735 Expert Mod 8TB
Thanks for the reply and sorry about the code I realized it after I had already clicked submit.

Can you please provide an example. If I make forcasts an array I won't be able to access the web method 'Details'.
First you make forcasts an array that holds a bunch of forcast information objects.
Then when you want to access a specific forcast you'll do something like:
Expand|Select|Wrap|Line Numbers
  1. net.webservicex.www.WeatherForecast forcast = new net.webservicex.www.WeatherForecast();
  2. net.webservicex.www.WeatherForecast forcasts[] = forcast.GetWeatherByZipCode("07747");
  3. int i;
  4. for(i=0;i<forcasts.length;i++)
  5. {
  6.     TextBox1.Text = TextBox1.Text +" "+ forcasts[i].Details;
  7. }
  8.  
(Please note that I usually work in VB.NET so this code may not work)

-Frinny
May 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
3
by: fazulu deen | last post by:
Hi all, For the following code : file_ptr = fopen("pass_fail.txt", "a"); // error line 393 fdisplay(file_ptr, "Test Passed"); fclose(file_ptr);
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.