去除空格
string name = "? ?abdcefg? Jackson? ";
前后空格都去除,用Trim:
string str2=name.Trim();
Console.WriteLine(name+"-"+str2+"H");
只去除前面空格,用TrimStart:
string str3 = name.TrimStart();
Console.WriteLine(name + "-" + str3 + "H");
只去除后面空格,TrimEnd:
string str4 = name.TrimEnd();
Console.WriteLine(name + "-" + str4 + "H");
標(biāo)簽: