Trim left String in C#

In this article we will discuss how to trim a string from left in C#.
  • 5925

The TrimStart method trims a string from the begging by removing white spaces from the start of a string.

The following code snippet shows how to trim a string from the start.

string firstName = "Mahesh";
string lastName = "Chand";
string age = "33";
string authorInfo = " Author "+ firstName + " " + lastName + " is "
    + age.ToString() + " years old.  ";
string:{0}", authorInfo);
:{0}", authorInfo.Length);
// Trim Start
string trimmedRightString = authorInfo.TrimEnd();
right string:{0}", trimmedRightString);
:{0}", trimmedRightString.Length);


Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.