专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »DotNet » 去除空格:分割后的string[]空格去除 »正文

去除空格:分割后的string[]空格去除

来源: 发布时间:星期四, 2009年2月12日 浏览:436次 评论:0


今天碰到个极其简单问题说简单也就是在解析时候碰到些奇怪然后我们要分割出来相应有用

str = "as asfje o as jf weo a sf ao alskj dflj aos f oas dfl l lksaf".Split(' ')后会有很多地方存着个空

需要去掉原以为也应该有remove思路方法找了下才知道不是这么用D也没找出思路方法后来看到有人写这个思路方法能实现就万岁了哈 

using ;

using .Collections.Generic;

using .Text;

using .Collections;



ConsoleApplication1

{

RemoveStringEmpty

{

void Main( args)

{

str = "as asfje o as jf weo a sf ao alskj dflj aos f oas dfl l lksaf";

.gif' />str = str.Split(' ');



List<> .gif' />list = List<>(.gif' />str);



for ( i = 0; i < .gif' />list.Count; i)

{

(.gif' />list[i] .Empty)

{

.gif' />list.Remove(.Empty);

i--;

}

}



.gif' />list.CopyTo(.gif' />str);



foreach ( ha in .gif' />str)

Console.WriteLine(ha);



Console.ReadLine;



}

}

}

using ;

using .Collections.Generic;

using .Text;

using .Collections;



ConsoleApplication1

{

RemoveStringEmpty

{

void Main( args)

{

str = "as asfje o as jf weo a sf ao alskj dflj aos f oas dfl l lksaf";

.gif' />str = str.Split(' ');



List<> .gif' />list = List<>(.gif' />str);



for ( i = 0; i < .gif' />list.Count; i)

{

(.gif' />list[i] .Empty)

{

.gif' />list.Remove(.Empty);

i--;

}

}



.gif' />list.CopyTo(.gif' />str);



foreach ( ha in .gif' />str)

Console.WriteLine(ha);



Console.ReadLine;



}

}

}

就这么简单没写全单步调试可以得到结果这样有关就被去掉了还有其他更好办法了么?请大家指点指点~谢过
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: