0

I need to extract an integer value from the end of a string, and I'm a little bit lost on algorithm functions/classes in C#.

Is there any sort of convenient class/function to help with this? Here is a sample string:
"omaha nebraska weather 2400"

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pseudorandom21
Featured Replies
  • 1

    [code]String myString = "omaha nebraska weather 2400"; int myInt = Int32.Parse(myString.Split(' ').Last());[/code] Read More

1
String myString = "omaha nebraska weather 2400";
int myInt = Int32.Parse(myString.Split(' ').Last());
0
String myString = "omaha nebraska weather 2400";
int myInt = Int32.Parse(myString.Split(' ').Last());

I'm not entirely sure that works.

int i;
                            if(Int32.TryParse((line.Split(' ').Last()),out i))
                            {

Oh sorry my tokens are sometimes separated by tabs...

Edited by pseudorandom21: n/a

0

I'm not entirely sure that works.

int i;
                            if(Int32.TryParse((line.Split(' ').Last()),out i))
                            {

Oh sorry my tokens are sometimes separated by tabs...

I finally found my answer too. string[] tokens = Regex.Split(line, @"\s+");

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.