return value c#

Below codes working and now I want to make it like return 2 value (lat, lng)
so the asp.net / c# can call it and get value
like
GetLocationConverter("1111")(0)
GetLocationConverter("1111")(1)

Above is my example only. Overall, want to get this as WCF service and return 2 value when it is consumed.

Thanks

XDocument xdoc = XDocument.Load("http://maps.googleapis.com/maps/api/geocode/xml?address=94043&sensor=false");

foreach (var geometry in xdoc.Descendants("geometry"))
{
    var location = geometry.Element("location");
    var lat = location.Element("lat");
    var lng = location.Element("lng");

    string latitude = lat.Value;
    string longtitude = lng.Value;
}
solution1368Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_davisCommented:
just create a small custom class with those two as properties  or a struct maybe and return an object of that
0
p_davisCommented:
other than that you can add to out parameters to those methods and set the value that way.
0
bhmahlerCommented:
I would write your own custom class.  Below is an example
public class GeoResult
{
    public double Lattitude { get; set; }
    public double Longitude { get; set; }

    public static GeoResult GetLatLon(string address)
    {
        XDocument xdoc = XDocument.Load("http://maps.googleapis.com/maps/api/geocode/xml?address=" + address + "&sensor=false");

        var geometry = xdoc.Descendants("geometry").FirstOrDefault();
        if(geometry != null)
        {
            var location = geometry.Element("location");
            if (location != null)
            {
                var lat = location.Element("lat");
                var lng = location.Element("lng");

                return new GeoResult()
                            {
                                Lattitude = double.Parse(lat.Value),
                                Longitude = double.Parse(lng.Value)
                            };
            }
        }

        return null;
    }
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

solution1368Author Commented:
how to consume it written in c# / asp.net
0
p_davisCommented:
What exactly do mean by consume in this scenario?  If you need to pass it back and forth through wcf make it a data contract. Otherwise, just make a public or private class on the client side.
0
p_davisCommented:
..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.