String Trimming Method C# with Example
using System; namespace CSharpFundamentals { class StringTrimmingMethod { private static void Main(string[] args) { String msg = " C# is COOL too "; Console.WriteLine("Trim Spaces from Both Side: {0}", msg.Trim()); String msg1 = "===== C# is COOL too ====="; Console.WriteLine("Trim Specified Character from Both Side: {0}", msg1.Trim('=')); String msg2 = "===== C# is COOL too ====="; Console.WriteLine("Trim Specified Character from Left Side: {0}", msg2.TrimStart('=')); Console.WriteLine("Trim Specified Character from Right Side: {0}", msg2.TrimEnd('=')); } } }