When i type in a string consisting of numbers and signs for example:
12 + 3
how can i split it and how can i convert parts of the string into integers?
been searching in the web for 2 hours didnt find anything apropreate :(
FilteR 0
Newbie Poster
Recommended Answers
Jump to PostHow about this:
string g = "12 + 3"; string[] MyInts = g.Split('+'); ArrayList RealInts = new ArrayList(); for(int i = 0; i < MyInts.Lenght; i++){ RealInts.Add(Convert.ToInt32(((string)MyInts[i]).Trim()); }
At the end you should get an array list of integers.
RealInts[0] = 12;
RealInts[1] = 3;…
All 3 Replies
Reply to this topic
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.