I have strings representing an angle, of the format ddd°mm'ss''.
I want to get to the three constituents: degrees, minutes and seconds.
I first chopped off the seconds like this:
angleString = “ddd°mm'ss''”;
string str = angleString.Substring(0, angleString.Length - 2);
Then I tried to do this, to get to the degrees,minutes and seconds:
string[] items = str.Split(new char[] { '°', '''});
But it gave an error on the ' character, saying: "empty char literal".
I solved by using this:
string[] items = str.Split(new char[] { '°', char.Parse("'") });
I find this rather clumsy.
It would be great if anyone over here can come up with a better way.
Could not find a solution elsewere. :o)

2 Years
Discussion Span
Last Post by JOSheaIV

I have to ask, why no Regex?

@"([\d]+)°([\d]+)'([\d]+)" (then match group 1,2, and 3)

Edited by JOSheaIV

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.