C#去掉字符串两端空格以及去掉字符串中多余空格保留一个空格

1 string str = " asdf asd saddf sdfwrqeqw a asdf ";
2 string[] strs = str.Trim().Split(new char[]{' '},StringSplitOptions.RemoveEmptyEntries);
3 string finallStr = string.Join(" ",strs);

 

posted @ 2017-12-07 17:00  liu_xh  阅读(2096)  评论(0编辑  收藏  举报