In the c# String Trim() method. Description Trim(Char[]). Removes all leading and trailing occurrences of a set of characters specified in an array.
Syntax
public string Trim()
public string Trim(params Char[])
Method | Description |
Trim(Char[]) | Removes all leading and trailing occurrences of a set of characters specified in an array from the current String object. |
Trim() | Removes all leading and trailing white-space characters from the current String object. |
Parameter
First method does not take any parameter. Second method takes a char array as parameter.
Return
It returns a string.
C# String Trim() Method Example
using System;
public class Program
{
public static void Main()
{
string str = "Hello FindAndSolve";
string str1 = str.Trim();
Console.WriteLine(str1);
}
}
Output
Hello FindAndSolve