Requires FrameWork 4.0 or later
... edit 1 ...
The string.Trim() method will
not remove any digit characters, but will remove all white-space characaters at the start and end of a string.
The second string.Trim(char[]) method will remove only characters you specify in the parameter array, and string.TrimStart(char[]), and string.TrimEnd(char[]) work the same way.
string.TrimStart, and string.TrimEnd, which require an array of char parameters char[] will not remove any character unless you specify it.
If you want to convert a string to a number, you
must remove any leading, or trailing, white-space !
... end edit 1 ...
I like to use the String.Concat operator to clean up strings so they contain only digits:
string allNumericString = String.Concat
(
YourString.Where(Char.IsDigit)
);
That will get rid of white space of all flavors, etc.
For string cleaning that allows the period to remain:
string allNumericWithDotString = string.Concat
(
YourString.Where(chr => (Char.IsDigit(chr) || (chr == '.')))
);
Do keep in mind that 'IsDigit is Unicode compatible, so, if you are dealing with Unicode fonts, some combinations of characters may be validated as digits, depending on context.