Rezoan
Rezoan

Reputation: 1787

How many records a List<> object can hold at a time in c#

I have a class:

  public class Person
    {
        public string PersonID { get; set; }
        public string RegistrationNo { get; set; }
        public DateTime RegistrationDate { get; set; }
    }

and i used a List object that will hold number of Person's record mapped from the database in my program. Database has millions of record and I am planning to take all this records at a time and put those record into the List. So my question is the List object capable of holding millions of data at a time or is there any limitation on it?

More specifically what is the limit of List object about holding number of record?

Upvotes: 2

Views: 5413

Answers (2)

Claudio Redi
Claudio Redi

Reputation: 68400

There is a limit of 2GB for storing objects in memory. You also have a limitation over the amount of items that a collection can handle as other already pointed out.

In any case, I'm pretty sure you don't have to test these limit getting million of records from database unless there is no other option, what is not the case for 99.999% of the cases.

Upvotes: 3

Debajit Mukhopadhyay
Debajit Mukhopadhyay

Reputation: 4172

It depends mainly on the size of the RAM of the PC and each Object size (In your case it will also depends the size of the RegistrationNo,PersonID etc.).

See the link below to get better Idea.

What's the max items in a List<T>?

Upvotes: 0

Related Questions