操作文本l流streamReader,使用如下代码,可以读取文本中的数据并进行数据解读
using (StreamReader sr=new StreamReader("data56006.txt"))
{
while((line=sr.ReadLine())!=null)//从文件读出每行并输出赋值
{
string[] stemp = line.Split(' ');
for (int i=0;i<stemp.Length;i++)
{
if (Convert.ToInt32(stemp[i])%2==0)
{ cnt2 = cnt2 + stemp[i] + "** "; }
else
{ cnt1 = cnt1 + stemp[i] + "** "; }
}
}