C#StringTrim

Removes all leading and trailing whitespace characters.

Syntax

str.Trim()

Example

Enter values below to update the example in real time.

string
Console
WriteLine
string text = "  hello world  ";
Console.WriteLine(text.Trim());   // "hello world"