size of arraylist in bytes

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!
windsofchangeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
testnCommented:
Why don't you serialize it first and then measure the size...
0
 
TransBindCommented:
Use the FileInfo class:
FileInfo info = new FileInfo(path);
long fileSize = info.Length;
0
 
sentosa_ganiCommented:
is sizeof(arraylist) any help?
0
 
TheAvengerCommented:
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

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
windsofchangeAuthor Commented:
that's what i feared. i actually now make some kind of estimation.
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.