求字符串子串时的错误?
int counter = 0;
string line;
System.IO.StreamReader file =new System.IO.StreamReader("1.txt");
while((line = file.ReadLine()) != null)
{
listBox1.Items.Add(line);
int a=line.LastIndexOf(" ");
listBox1.Items.Add(a.ToString()+" "+line.Length);
listBox1.Items.Add(line.Substring(a,line.Length));
counter++;
}
未处理的“System.ArgumentOutOfRangeException”类型的异常出现在 mscorlib.dll 中。
其他信息: 索引和长度必须引用该字符串内的位置。
listBox1.Items.Add(line.Substring(a,line.Length));这句怎么会错?
string line;
System.IO.StreamReader file =new System.IO.StreamReader("1.txt");
while((line = file.ReadLine()) != null)
{
listBox1.Items.Add(line);
int a=line.LastIndexOf(" ");
listBox1.Items.Add(a.ToString()+" "+line.Length);
listBox1.Items.Add(line.Substring(a,line.Length));
counter++;
}
未处理的“System.ArgumentOutOfRangeException”类型的异常出现在 mscorlib.dll 中。
其他信息: 索引和长度必须引用该字符串内的位置。
listBox1.Items.Add(line.Substring(a,line.Length));这句怎么会错?
...全文
相关推荐
数据结构第四章考试题库(含答案).doc
数据结构第四章考试题库(含答案).doc
xuanze.zip_php代码
初学入门PHP代码,数学题自动出题,测试,验收学习成果
2004年下半年高等教育自学考试全国统一命题考试数据库及其应用试题及答案.docx
2004年下半年高等教育自学考试全国统一命题考试数据库及其应用试题及答案
C语言求两个字符串的最长公共子串
主要介绍了C语言求两个字符串的最长公共子串,实例分析了C语言操作字符串的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
字符串的子串删除问题
本文探讨了Codeforces Round#452 (Div. 2) F题的两种做法。 关键词:解题报告; 数据结构; 字符串;


