的代码是:需要帮助,阅读一些C#
private static void loadAccounts()
{
using (TextReader tr = new StreamReader("accounts.txt"))
{
string line = null;
while ((line = tr.ReadLine()) != null)
{
String[] details = line.Split('\t');
accounts.Add(details[0].Substring(6) +
":" + details[1].Substring(10));
}
}
}
应该怎样文本文件包含/应如何contense被格式化。 我已经试过: 用户名:密码 用户名/吨密码
,但得到的错误
的错误是:
System.ArgumentOutOfRangeException:的startIndex不能大于字符串的长度。 在System.String.InternalSubStringWithChecks(的Int32的startIndex,的Int32长度,布尔fAlwaysCopy) 在System.String.Substring(的Int32的startIndex,的Int32长度) 在System.String.Substring(的Int32的startIndex) 在Test.Program.loadAccounts( ) c:\ Users \ Documents \ SharpDevelopProjects \ Test \ Test \ Program.cs:line 148 at Test.Program.Main(String [] args)in c:\ Users \ Documents \ SharpDevelopProjects \ Test \ Test \ Program.cs:line 26
'\ t'是一个制表符。即Tab键 – 2014-10-17 06:43:36
您的问题标题没有太多说明。请参考[我如何写一个好的标题?](http://meta.stackexchange.com/questions/10647/how-do-i-write-a-good-title)。 – 2014-10-17 06:44:11
你得到了什么错误? – Catwood 2014-10-17 06:44:59