Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# Parse A Word From A String
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01283001
Message ID:
01283031
Vues:
15
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform