什么,我想要做的就是从text.txt文件读取的数字,它们加起来 该文件包含对自己行从文件中添加数字
86
97
144
26
所有。我很为难:L
这是我的代码:
namespace CH13EX1
{
class CH13EX1
{
static void Main(string[] args)
{
// opens the file
StreamReader inFile;
// tests to make sure the file exsits
if (File.Exists("text.txt"))
{
// declrations
string inValue;
int total;
int number;
// makes infile the file
inFile = new StreamReader("text.txt");
// loop to real the files
while ((inValue = inFile.ReadLine()) != null)
{
number = int.Parse(inValue);
Console.WriteLine("{0}", number);
}
}
}
}
}
大时,它的工作? – Thomas 2013-05-01 08:16:08
你难以接受哪行代码? – 2013-05-01 08:16:09
这里有很多专家可以给你答案,但是我觉得从长远来看,这对你无能为力。看起来你已经完成了所有困难的部分。你究竟在为什么而挣扎? – 2013-05-01 08:16:09