A simple regular expression can extract a number, and then you can parse it:
int.Parse(Regex.Match(yourString, @"\d+").Value, NumberFormatInfo.InvariantInfo);
If a string can contain several numbers, you can simply iterate over the matches found using the same Regex:
for (Match match = Regex.Match(yourString, @"\d+"); match.Success; match = match.NextMatch()) { x = int.Parse(match.Value, NumberFormatInfo.InvariantInfo);
source share