0

hello

I'm beginner on c#. I'm getting this error:

System.NullReferenceException was unhandled

and my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GittiGidiyor;
using GittiGidiyor.City;

namespace ConsoleApplication1
{ 
    class Program
    {
        static void Main(string[] args)
        {
            [B]CityService cityservice = ServiceProvider.getCityService();[/B]
            cityServiceResponse response = cityservice.getCities(1, 3, "", "tr");


            if (response != null && response.ackCode.ToString().Equals("success"))
            {
                cityType[] city = response.cities;
                foreach (cityType cities in city)
                {

                    Console.WriteLine("citycode :" + cities.trCode + " / cityname :" + cities.cityName);
                }
            }
            else
            {
                Console.WriteLine("errorid :" + response.error.errorId);
                Console.WriteLine("errorcode :" + response.error.errorCode);
                Console.WriteLine("errormessage :" + response.error.message);
            }
        }              
        }
    }

I've bolded line about getting error
I'll be glad if someone help me
thanks

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by blax00
0

Given I have no idea what GittiGidiyor is. I'll take a guess based on my own experiences. ServiceProvider.getCityService(); is not being defined/set and is not static. If it was static you could do that, if it isn't you'll have to define it as a ServiceProvider first:

ServiceProvider sProvider = new ServiceProvider();
CityService cityservice = sProvider.getCityService();

If that doesn't work. Type out (assuming you're using VC#) GittiGidiyor. and see what options it has available to use.

0

Yes doens't work. Thats mean not static.
I'll type gittigidiyor.
Thank you for advice

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.