sizeof in C# just used for valuetypes in unsafe mode(in version 2 no neeed for unsafe mode)
I don't know what could be good for this?
you can try
GC.GetTotalMemory Method after and befor creating your object,(but you should know other threads may run concurrently and that method doesn't give you a proper result)
I myself tried something now
Code:
class simple
{
int a=0;
int c=0;
}
private double size()
{
double c=GC.GetTotalMemory(true);
simple s=new simple();
return GC.GetTotalMemory(true)-c;
}
it gives me 16 bytes if I consider just one integer field it gives me 12 bytes that 4 bytes was for an integer field(the sizeof(int) is 4 bytes)
_____________
Mehdi.
software student.