在VS2010环境下的C#程序,在RRB[i]=int.parse(RR[i])处出现"值不能为null,参数名:string"的错误,求解答
StreamReadersr=newStreamReader(@"C:\MyGod.txt");intnumLine=File.ReadAllLines(@"C:\MyG...
StreamReader sr = new StreamReader(@"C:\MyGod.txt");
int numLine = File.ReadAllLines(@"C:\MyGod.txt").Length;//numLine为该txt的总行数
string p = "";
string[] RR=new string[numLine];
int count = 1;//从第1行开始读起
int Lineth = 0;//数组的第0个数值
int[] RRB = new int[numLine];//RRB的长度与RR的长度一致
while (!sr.EndOfStream)
{
p = sr.ReadLine();//p为txt上读取的第N行的内容
if (count > 3)
{
if (Lineth <= numLine)
{
var sliceUsingSubstring = p.Substring(0, 3);//获取头3个字符
//p = p.Replace("\r","\n");
RR[Lineth] = p;
Lineth++;
}
}
count++;
}
sr.Close();
//把string 类型的RR逐一转换为int 类型的RRB;
for (int i = 4; i < numLine; i++)
{
RRB[i] = int.Parse(RR[i]);
} 展开
int numLine = File.ReadAllLines(@"C:\MyGod.txt").Length;//numLine为该txt的总行数
string p = "";
string[] RR=new string[numLine];
int count = 1;//从第1行开始读起
int Lineth = 0;//数组的第0个数值
int[] RRB = new int[numLine];//RRB的长度与RR的长度一致
while (!sr.EndOfStream)
{
p = sr.ReadLine();//p为txt上读取的第N行的内容
if (count > 3)
{
if (Lineth <= numLine)
{
var sliceUsingSubstring = p.Substring(0, 3);//获取头3个字符
//p = p.Replace("\r","\n");
RR[Lineth] = p;
Lineth++;
}
}
count++;
}
sr.Close();
//把string 类型的RR逐一转换为int 类型的RRB;
for (int i = 4; i < numLine; i++)
{
RRB[i] = int.Parse(RR[i]);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询