Sunday, 18 October 2015

String.Trim(), String.TrimStart() and String.TrimEnd() Methods in String in C#

using System;
class Program
{
    static void Main()
    {
        string s = "     rao12345@gmail.com     ";
        //Trim() removes white space from Beginning and end of the string
        Console.WriteLine(s.Trim()+"Done");
        //TrimStart() removes white space from Beginning of the string
        Console.WriteLine(s.TrimStart() + "Done");
        //TrimEnd() removes white space from end of the string
        Console.WriteLine(s.TrimEnd() + "Done");
    }
}

No comments:

Post a Comment