Alphanumeric to numeric only
.net, c#
Solution
LINQ Solution:
return new string(str.Where(char.IsDigit).ToArray());
Not sure if it's more efficient; at-least it's not regex!
Problem
Looking for fast/efficient ways to convert an alphanumeric to a number only string e.g. +123-456/7890 becomes 1234567890 etc. the existing code is ``` foreach(char c in str.ToCharArray() ) if ( char.IsDigit(c) ) stringBuilder.Append(c); return stringBuilder.ToString(); ```