110,566
社区成员
发帖
与我相关
我的任务
分享
StreamReader sr = new StreamReader(file,Encoding.GetEncoding("GBK"));
string temp = null;
while ((temp = sr.ReadLine()) != null && !sr.EndOfStream)
{
PostEntity entity = new PostEntity();
if (temp.Contains("id=") )
{
FillEntity(entity, temp);
list.Add(entity); //调试显示当list.count>5160时报错,异常信息为 索引超出的数组限制
}
}
public void Add(T item)
{
if (this._size == this._items.Length)
{
this.EnsureCapacity(this._size + 1);
}
this._items[this._size++] = item;
this._version++;
}
List<string> stringList = new List<string>();
while (true)
{
stringList.Add("abc");
}
private void FillEntity(PostEntity entity, string line)
{
if (String.IsNullOrEmpty(line)) return;
//找出url
string str1 = System.Text.RegularExpressions.Regex.Split(line, "</a></td><td colspan=2><a href=")[0];
string[] str1s = System.Text.RegularExpressions.Regex.Split(str1, "target=_blank>");
//找出url中的tid
entity.title = str1s[1];
string tid = System.Text.RegularExpressions.Regex.Split(str1s[0], "tid=")[1];
entity.tid= Convert.ToInt32(tid.Replace("\"","").TrimEnd());
//找出postdate
string[] str2s = System.Text.RegularExpressions.Regex.Split(line, "<td colspan=2>");
string time = System.Text.RegularExpressions.Regex.Split(str2s[2], "</td>")[0];
entity.postDate = Convert.ToDateTime(time);
}
StreamReader sr = new StreamReader(file,Encoding.GetEncoding("GBK"));
string temp = null;
while ( !sr.EndOfStream &&(temp = sr.ReadLine()) != null)
{
PostEntity entity = new PostEntity();
if (temp.Contains("id=") )
{
FillEntity(entity, temp);
list.Add(entity); //调试显示当list.count>5160时报错,异常信息为 索引超出的数组限制
}
}
看不懂什么错,随便试试这个吧