Solved

size of arraylist in bytes

Posted on 2003-12-11
5
427 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
ID: 9924259
Why don't you serialize it first and then measure the size...
0
 
LVL 7

Expert Comment

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

Expert Comment

by:sentosa_gani
ID: 9925161
is sizeof(arraylist) any help?
0
 
LVL 20

Accepted Solution

by:
TheAvenger earned 500 total points
ID: 9926580
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
ID: 9927599
that's what i feared. i actually now make some kind of estimation.
thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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