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"

String myString = "omaha nebraska weather 2400";
int myInt = Int32.Parse(myString.Split(' ').Last());
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...

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+");

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.