Solved

size of arraylist in bytes

Posted on 2003-12-11
5
392 Views
Last Modified: 2011-10-03
hi

is there a way to find out the size (in bytes) of an arraylist and all of its contents?

(i need to know the file-size before I serialize the arraylist.)

thanks!
0
Comment
Question by:windsofchange
5 Comments
 
LVL 18

Expert Comment

by:testn
Comment Utility
Why don't you serialize it first and then measure the size...
0
 
LVL 7

Expert Comment

by:TransBind
Comment Utility
Use the FileInfo class:
FileInfo info = new FileInfo(path);
long fileSize = info.Length;
0
 

Expert Comment

by:sentosa_gani
Comment Utility
is sizeof(arraylist) any help?
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
Comment Utility
There is no way to get the size of non value types. Maybe you can try to calculate it yourself based on the knowledge how many and what objects are in the ArrayList and also by seeing how much bytes the ArrayList data takes. So just make some tests like serializing the ArrayList empty, then with 1, 2 objects and you will figure it out. If you use objects like strings, I suppose it will be harder, But if you store objects like int, it will work.
0
 

Author Comment

by:windsofchange
Comment Utility
that's what i feared. i actually now make some kind of estimation.
thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now