Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding values within strings 1

Status
Not open for further replies.

bernardmanning

Programmer
Oct 14, 2003
61
GB
Hi ,

I wonder if somebody could give me a push in the right direction with this one as I'm pretty new to string manipulation in C#.

if I have strings in the following formats ;

"2 Feet 6 inches"
"12 Feet 11 inches"

what's the best way to be able to retrieve the numerical value for the feet and the inches?

Thanks, Bernard...






 
If the format is always the same you can split the string on spaces.

String[] stringValues = myString.Split(" ")

The result will be:

String(0) = '2'
String(1) = 'Feet'
String(2) = '6'
String(3) = 'Inches'

You can then easily get the values as shown above.

Regards, Ruffnekk
---
Is it my imagination or do buffalo wings taste just like chicken?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top