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)

I'd just escape it:

string[] items = str.Split(new char[] { '°', '\''});

Yes of course! How can I forget that!
Thanks!

I have to ask, why no Regex?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.