C# 移除字串所有的前置和後端空白字元(String.Trim 方法)
C# 移除字串所有的前置和後端空白字元(String.Trim
方法)
資料來源: https://msdn.microsoft.com/zh-tw/library/t97s7bs3(v=vs.100).aspx
using public class { public static void Main() { Console.Write(“Enter string firstName = Console.ReadLine(); Console.Write(“Enter string middleName = Console.ReadLine(); Console.Write(“Enter string lastName = Console.ReadLine(); Console.WriteLine(); Console.WriteLine(“You firstName, string name = (firstName.Trim() + ” lastName.Trim(); Console.WriteLine(“The } } // // Enter your first name: John // Enter your middle name or initial: // Enter your last name: Doe // // You entered ‘ John // The result is John Doe |