

If the current string equals Empty or all the characters in the current instance consist of white-space characters, the method returns Empty.

Instead, it returns a new string in which all leading and trailing white space characters found in the current instance are removed. If the Trim method removes any characters from the current instance, this method does not modify the value of the current instance. To remove white-space characters between words in a string, use. For example, if the current string is " abc xyz ", the Trim method returns "abc xyz". Each leading and trailing trim operation stops when a non-white-space character is encountered. The Trim method removes from the current string all leading and trailing white-space characters. ' The following is possible output from this example: using namespace System Īrray^ charsToTrim = '.", _ĭim name As String = ((firstName.Trim() + " " + middleName.Trim()).Trim() _Ĭonsole.WriteLine("The result is " + name + ".") The following example uses the Trim(System.Char) method to remove space, asterisk (*), and apostrophe (') characters from a string. If no characters can be trimmed from the current instance, the method returns the current instance unchanged. If trimChars is null or an empty array, white-space characters are removed instead. The string that remains after all occurrences of the characters in the trimChars parameter are removed from the start and end of the current string. The other characters were ignored because they didn't exist in the string.An array of Unicode characters to remove, or null. In this example, only the trailing period and spaces from before # and after the word test were removed. The following example provides a list of possible characters to remove from a string. Remove specified characters from both sides of string The following example removes spaces from before and after the word test. Remove the space character from both sides of string

