System.NullReferenceException was unhandled

Discussion in 'C#' started by blax00, Sep 1, 2010.

  1. blax00

    blax00 New Member

    Joined:
    Sep 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hello

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

    System.NullReferenceException was unhandled

    and my code:

    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
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice