Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# Parse A Word From A String
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01283001
Message ID:
01283031
Views:
14
>I'm gonna convert it to an int.
>
>There will always be a number in this position.
>
>
>>>
string s = "+OK 1 2729"
>>>
>>>How do I parse the '1' from the above string?
>>
>>What do you want to do with it? Remove it? Obtain the value that is always in that space?

Depending on what the string can look like, this may work:
string s = "+OK 1 2729"
string num = s.Substring(4, s.IndexOf(" ", 4) - 3);
int result;
int.TryParse(num, out result);
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform