What's the max items in a List?

后端 未结 6 1401
闹比i
闹比i 2020-11-29 08:47

Anybody know what the max number of items in a List is?

How do I increase that size? Or is there a collection that takes infinite items? (as much as would fit in me

6条回答
  •  半阙折子戏
    2020-11-29 09:35

    On a x64 Machine, using .Net Framework 4 (Not the Client Profile), compiling for Any CPU in Release mode, I could chew up all the available memory. My process is now 5.3GB and I've consumed all available memory (8GB) on my PC. It's actually a Server 2008 R2 x64.
    I used a custom Collection class based on CollectionBase to store 61,910,847 instances of the following class:

    public class AbbreviatedForDrawRecord {
        public int DrawId { get; set; }
        public long Member_Id { get; set; }
        public string FactorySerial { get; set; }
    
        public AbbreviatedForDrawRecord() {
    
        }
    
        public AbbreviatedForDrawRecord(int drawId, long memberId, string factorySerial) {
            this.DrawId = drawId;
            this.Member_Id = memberId;
            this.FactorySerial = factorySerial;
        }
    }
    

提交回复
热议问题