作者chhuang (口白人生)
看板C_Sharp
標題Re: [問題] 請問split問題
時間Thu Sep 6 10:31:59 2007
StreamReader sr = new StreamReader("s1.txt");
while (sr.Peek() != -1)
{
string str = sr.ReadLine();
string[] words1 = Regex.Split(str, @"\s+",
RegexOptions.IgnorePatternWhitespace);
MessageBox.Show(string.Format("'{0}'-'{1}'-'{2}'-'{3}'", words1[0],
words1[1], words1[2], words1[3]));
}
sr.Close();
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.239.131
推 liptonbin:還是一樣耶 我數字放 55(空格+TAB)56(空格空格)就不行 09/06 10:47
→ liptonbin:然後跳出請確定清單索引的最大值必須小於清單的大小 09/06 10:48
→ liptonbin:55(空格+TAB)56(空格空格)57(TAB+空格)58 09/06 10:49
→ chhuang:應該是你的寫法出問題.... 09/06 10:55
→ chhuang:乾脆貼你完整的程式碼出來吧.... 09/06 11:05
推 liptonbin:可以了 謝謝 09/06 13:33