S
Sheila Jones
Hello,
Can somebody tell me how to do the following, please?
I have written a 'GridReference' class to encapsulate map locations. It has
a constructor that takes a couple of doubles, representing latitude and
longitude, i.e.
public GridReference(double latitude, double longitude) {
...
}
I now want to write another constructor that takes two strings. The strings
again contain latitude and longitude, but formatted as degrees, minutes and
seconds, for example: 52° 39' 27.246"N.
How do I write this second constructor so that it converts the strings to
the double equivalents (I can do that), then 'calls' the first constructor
with these values? Sort of like this:
public GridReference(string latitude, string longitude) {
double lat = ConvertToDouble(latitude);
double lng = ConvertToDouble(longitude);
//somehow jump to GridReference(lat, lng);
}
Thanks.
Can somebody tell me how to do the following, please?
I have written a 'GridReference' class to encapsulate map locations. It has
a constructor that takes a couple of doubles, representing latitude and
longitude, i.e.
public GridReference(double latitude, double longitude) {
...
}
I now want to write another constructor that takes two strings. The strings
again contain latitude and longitude, but formatted as degrees, minutes and
seconds, for example: 52° 39' 27.246"N.
How do I write this second constructor so that it converts the strings to
the double equivalents (I can do that), then 'calls' the first constructor
with these values? Sort of like this:
public GridReference(string latitude, string longitude) {
double lat = ConvertToDouble(latitude);
double lng = ConvertToDouble(longitude);
//somehow jump to GridReference(lat, lng);
}
Thanks.