作者g548462 (里长伯)
看板C_Sharp
标题[问题] 字串切割
时间Tue Jun 21 17:39:12 2011
解决了...最後程式码
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)