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();
}
}
}
Tidak ada komentar