Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[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 occurrences of a set of characters specified in an array from the current String object.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Function Trim ( _
ParamArray trimChars As Char() _
) As String
public string Trim(
params char[] trimChars
)
public:
String^ Trim(
... array<wchar_t>^ trimChars
)
member Trim :
trimChars:char[] -> string
public function Trim(
... trimChars : char[]
) : String
Parameters
- trimChars
Type: array<System. . :: . .Char> [] () [] []
An array of Unicode characters to remove, or nullNothingnullptrunita null reference (Nothing in Visual Basic).
Return Value
Type: System. . :: . .String
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. If trimChars is nullNothingnullptrunita null reference (Nothing in Visual Basic) or an empty array, white-space characters are removed instead.
Remarks
The Trim method removes from the current string all leading and trailing characters that are in the trimChars parameter. Each leading and trailing trim operation stops when a character that is not in trimChars is encountered. For example, if the current string is "123abc456xyz789" and trimChars contains the digits from "1" through "9", the Trim method returns "abc456xyz".
If the current string equals Empty or all the characters in the current instance consist of characters in the trimChars array, the method returns Empty.
If trimChars is null Nothing nullptr unit a null reference (Nothing in Visual Basic) or an empty array, this method removes any leading or trailing characters that result in the method returning true when they are passed to the Char.IsWhiteSpace method,
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.