小编Mit*_*ell的帖子

内存不足异常

我有一个类型列表,其中包含(string,string,string,string,int,DateTime,DateTime)字符串组合中的字符总数等于28.

我在一个文件中读到填充列表,该列表将在列表中以19,000,000(一千九百万)个这些对象结束.

我在文件中读到并添加到列表中

public void ReadDocGrabValues(string fileREAD)
{
    using (var file = new StreamReader(fileREAD))
    {
        var j = file.ReadLine();

        while (j != null)
        {
            mylist.Add(new IDandAGE(j.Substring(0, 15), j.Substring(16, 1), j.Substring(18, 6), j.Substring(25, 6), 0, DateTime.Today, DateTime.Today));
            j = file.ReadLine();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

哪个应该不是问题.然后,我遍历整个列表,从两个字符串中计算出DateTime对象.

public void ConvertYOBDOI()
{
    foreach (IDandAGE x in mylist)
    {
        string IssueDate = (x.StringDOD.Substring(0,4) + "-" + x.StringDOD.Substring(4,2) + "-01");
        string BirthDate = (x.StringYOB.Substring(0,4) + "-" + x.StringYOB.Substring(4,2) + "-01");
        x.DeathDate= DateTime.Parse(DeathDate);
        x.YearOfBirth = DateTime.Parse(BirthDate);

     }
} …
Run Code Online (Sandbox Code Playgroud)

c# exception list out-of-memory

3
推荐指数
1
解决办法
183
查看次数

标签 统计

c# ×1

exception ×1

list ×1

out-of-memory ×1