In C#, we use Trim function to remove spaces or new lines from the beginning or ending of string.
There are three Trim methods in .net String Class-
// Input String String st = “ Hello World ”; // Call Trim instance method. String st_Trim = st.Trim(); String st_TrimStart = st.TrimStart(); String st_TrimEnd = st.TrimEnd();
st_Trim = “Hello World”
st_TrimStart = “Hello World ”
st_TrimEnd = “ Hello World”