日期:2014-05-19  浏览次数:20457 次

字符串分隔符问题
string   aa= "YA   BA   HA   KA   LA   MA   JA   VA   W5   S2 "
怎么能把它一个一个取出来

------解决方案--------------------
string aa = "YA BA HA KA LA MA JA VA W5 S2 ";
string[] array = aa.Split( ' ');
------解决方案--------------------
string[] str = aa.Split( ' ');

这样 str[0] = "YA ",str[1] = "BA ",str[2] = "HA "依此类推
------解决方案--------------------
using System;

public class SplitTest {
public static void Main() {

string words = "this is a list of words, with: a bit of punctuation. ";

string [] split = words.Split(new Char [] { ' ', ', ', '. ', ': '});

foreach (string s in split) {

if (s.Trim() != " ")
Console.WriteLine(s);
}
}
}