views:

31

answers:

1

Hello,

I'm receiving deserialized object using WCF (trying to get latitude and longitude using google api) however after that I need to get inside that object I received and obtain values for two properties which I'm interested in: public double Lat { get; set; } public double Lng { get; set; } Those are nested inside the object.

Here you can find structure of the object I'm receiving.

[DataContract]
  class GeoResponse
  {
    [DataMember(Name = "status")]
    public string Status { get; set; }

    [DataMember(Name = "results")]
    public CResult[] Results { get; set; }

    [DataContract]
    public class CResult
    {
      [DataMember(Name = "geometry")]
      public CGeometry Geometry { get; set; }
    }

    [DataContract]
    public class CGeometry
    {
      [DataMember(Name = "location")]
      public CLocation Location { get; set; }
    }

    [DataContract]
    public class CLocation
    {
      [DataMember(Name = "lat")]
      public double Lat { get; set; }

      [DataMember(Name = "lng")]
      public double Lng { get; set; }   
    }         
  }

And here is the view of the object "res" including those two properties and their values. I'll than use L2S to put those values inside DB. I'm new in c# and programming overall so question might be trivial but will appreciate any guidance how to solve it.

http://img85.imageshack.us/i/92453822.jpg/

A: 

something like:

var loc = responseObj.Results[0].GeoResponse.Geometry.Location;

that should then give you the data via loc.Lat and loc.Lng.

Marc Gravell