You can use
Regular Expression[
^] to get the value or validate input.
string valueString = System.Text.RegularExpressions.Regex.Replace(Txt1.Text, @"[^\d]", string.Empty, System.Text.RegularExpressions.RegexOptions.Compiled);
int b = int.Parse(valueString);
This will get you these outputs:
"10tons wast and 8 tons of stone" => 108
"108" => 108
"Hello Peter, please call me at (0)47-784-9787-1045" => 04778497871045
You have to be more specific. What if you have a value of "10tons wast and 8 tons of stone".
Do you then what the integer value to be "108" or just "10" or "8" ?