string去空格

众所周知,string字符串去除空格的方法有trim()和replace(),区别在于trim()去首尾的空格,但是不能去中间的,而replace可以去除所有的空格。

  1. string data1=" a b c ";
  2. data1=data1.trim();

结果为"a b c"。

  1. string data1="a b c ";
  2. data1=data1.Replace(" ", "")

结果为“abc”。

上一篇:javascript-test1


下一篇:网络通信 --> 消息队列