Share via


Trim Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Removes all leading and trailing white-space characters from the current String object.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function Trim As String
public string Trim()
public:
String^ Trim()
member Trim : unit -> string 
public function Trim() : String

Return Value

Type: System. . :: . .String
The string that remains after all white-space characters are removed from the start and end of the current string.

Remarks

The Trim method removes from the current string all leading and trailing white-space characters. Each leading and trailing trim operation stops when a non-white-space character is encountered. For example, if the current string is "   abc   xyz   ", the Trim method returns "abc   xyz".

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

White-space characters are defined by the Unicode standard. The Trim()()()() method removes any leading and trailing characters that produce a return value of true when they are passed to the Char.IsWhiteSpace method.

.NET Framework Security

See Also

Reference

String Class

Trim Overload

System Namespace