Console.Write("Please enter the name of the location: ");
string locationName = Console.ReadLine();
var location = new GoogleLocationService();
var point = location.GetLatLongFromAddress(locationName);
double latUn = point.Latitude;
double lngUn = point.Longitude;
float lat = Convert.ToSingle(latUn);
float lng = Convert.ToSingle(lngUn);
var loc = location.GetRegionFromLatLong(latUn, lngUn).Name;
I am using the following code to find the coordinates of a certain location and store them into variables latUn and lngUn. The variable loc is used to get the exact name, but every time I try to return var loc, it gives me a nullReferenceException.