求字符串子串时的错误?
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));这句怎么会错?