Re: How to know a class 's size?




Kevien Lee wrote:

If there are some int,string ,ushort filed in a class,How to find out
how it would cost of the memery?

Hi Kevien

I have a similar problem and as you can see from the other posts, the
sizeof function only works on value types, so not much use for objects.

Personally I just serialize the object to either a temp file (or
memory) and check the stream pointer or file length afterwards (which
is your object size!). It's a bit clunky but it works.

Hope this helps

Shane

.