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)
ddanbe
2,724
Professional Procrastinator
Featured Poster
Recommended Answers
Jump to PostI'd just escape it:
string[] items = str.Split(new char[] { '°', '\''});
All 3 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
JOSheaIV
119
C# Addict
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.