Delete Space use Trim C#


 

https://www.tutlane.com/tutorial/csharp/csharp-string-trim-method-trimstart-trimend


using System;

namespace Tutlane
{
    class Program
    {
        static void Main(string[] args)
        {
           // Trim Whitespaces
           string str1 = " Welcome";
           string str2 = " to ";
           string str3 = " Tutlane";
           Console.WriteLine("Before Trim: {0} {1} {2}", str1, str2, str3);
           Console.WriteLine("After Trim: {0} {1} {2}", str1.Trim(), str2.Trim(), str3.Trim());
           char[] trimChars = { '*''@'' ' };
           // Trim with Characters
           string str4 = "@@** Suresh Dasari **@";
           Console.WriteLine("Before Trim: {0}", str4);
           Console.WriteLine("After Trim: {0}", str4.Trim(trimChars));
           Console.WriteLine("\nPress Enter Key to Exit..");
           Console.ReadLine();
        }
    }
}



Delete Space use Trim C# Delete Space use Trim C# Reviewed by Leo on Mei 24, 2022 Rating: 5

Tidak ada komentar

About me

About Me

My name is Joanne Doe, a lifestyle photographer and blogger currently living in Osaka, Japan. I write my thoughts and travel stories inside this blog.