I'm trying to retrieve lat long from google maps using address. But when it's null my program throws null reference exception. How can I avoid this? I've tried !Double.IsNaN(point.Latitude
) and if (point.Latitude != null)
but it anyway throws an exception
foreach (string line in File.ReadLines(@"path of txt file"))
{
var locationService = new GoogleLocationService();
var point = locationService.GetLatLongFromAddress(line);
if (!Double.IsNaN(point.Latitude) || !Double.IsNaN(point.Longitude))
{
//do something
}
else
{
var latitude = point.Latitude;
var longitude = point.Longitude;
}
}
point.Latitude is type of double. I'm using GoogleMaps.LocationServices
I'm checking addresses from txt file, so some google can't find some addresses in map and because they're being null