How to find the Size of an object in VB.NET ?

Hi

I want to find the Size of an object in VB.NET. Can you please let me know how this can be done ? Similarly I want to find the Size of a string also in VB.NET. Can you please let me know how to do that ?

Thanks
milani_lucieAsked:
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.

käµfm³d 👽Commented:
There is no way to get the size of an object in VB.NET. As for the string, the best you can do is Len(stringVariable), which returns the number of characters or then optimum number of bytes taken up by the string.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Could you be a little more specific?...what are you trying to do here?  Are you working with some external API that needs the size of something?
0
milani_lucieAuthor Commented:
I will have an ParentObject with SubObjects, during runtime i need to check the size of the ParentObject. If its size is more than 100 K then i do not want to do anything. If it is less than 100 K i want to do some operations on that.

Is there something like SIZEOF()  ?

Thanks
0
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

srikanthreddyn143Commented:
I dnt think we have something like that. we have SizeOf But its for unmanaged code.For this
http://msdn.microsoft.com/en-us/library/y3ybkfb3.aspx

Normally you can serialize into binary and get the size of that binary value
0
milani_lucieAuthor Commented:
srikanthreddyn143:

Normally you can serialize into binary and get the size of that binary value.

Can you please provide me the sample code ? Appreciate your time and patience !

Thanks

0
srikanthreddyn143Commented:
Milani,

Use this func

Len(Object)

This retruns size in number of  bytes
0

Experts Exchange Solution brought to you by

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
srikanthreddyn143Commented:
why B Grade didn't it clear?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.