I have a requirement to find and extract a number contained within a string.
For example, from these strings:
string test = \"1 test\" string test1 =
Here's a Linq version:
Linq
string s = "123iuow45ss"; var getNumbers = (from t in s where char.IsDigit(t) select t).ToArray(); Console.WriteLine(new string(getNumbers));