Stripping everything except numbers from string?Solved
is there a easy way to strip a string of all letters and only allow numbers?

First, what comes to mind

string ToNumbersOnly(string input){
            return string.Join(string.Empty, input.ToList().RemoveAll(c => !char.IsNumber(c)));
        }
5ba0b9633e817.png?uid=5ba0b9716c220 2CHEVSKII

First, what comes to mind

string ToNumbersOnly(string input){
            return string.Join(string.Empty, input.ToList().RemoveAll(c => !char.IsNumber(c)));
        }


yes, but rather IsDigit than isNumber... (exlude e.g. ½)

5d2e4d835505b.png Ultra


yes, but rather IsDigit than isNumber... (exlude e.g. ½)

Depends on what hes trying to achieve since he has not told us about that
Of course, but it's good to know as it can become a "trap" in future :)
It's a trap! 0_o
                   
Mr. Ts3hosting had asked to keep numbers in a string. I think it's pretty clear what he would like to achieve. ½ is not a number and it would raise an exception in conversion/parsing.
Thanks yes im looking for if somone inputs say ajkdsfa/?sd@&^^@%^(jk it fails i want just inputs of 23489573454.
Ts3hosting
Thanks yes im looking for if somone inputs say ajkdsfa/?sd@&^^@%^(jk it fails i want just inputs of 23489573454.
Oh, if you want to only allow number inputs and ignore all others - use TryParse from some number type
so what im geting at is   if string = "32?<$%&*38748"  return;      if string = "478348723494" good string do whatever
I got it working thanks for the help guys.
Locked automatically