[問題] 字串切割(解決)

看板C_Sharp (C#)作者 (里長伯)時間14年前 (2011/06/21 17:39), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
解決了...最後程式碼http://pastie.org/2100722 檔案內容 1 3 5 7 2 4 6 8 ---------------------------------------------------- 我寫了一個讀檔 while (!freader.EndOfStream) { token = freader.ReadLine(); intToken = Convert.ToInt32(token.Split(" "));// 這邊不會切字串.. foreach (int i in intToken) { total = total + i; count++; } } 全部程式碼在這邊:http://pastie.org/2100591 我想說把讀到的token切割完轉成數字存在intToken陣列裡 然後計算檔案裡數字的總和跟值的個數 裡面宣告是 string token; int[] intToken=new int[10]; 剛學程式的新手~書好像因為這個太簡單結果沒寫ㄒ_ㄒ 爬文好像沒爬到有人問這麼簡單的東西.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.25.118.131 ※ 編輯: g548462 來自: 163.25.118.131 (06/21 18:19)
文章代碼(AID): #1E06R3Qd (C_Sharp)
文章代碼(AID): #1E06R3Qd (C_Sharp)