Home All Groups Group Topic Archive Search About
Author
3 Aug 2006 8:21 PM
Leon_Amirreza
I dont think marshal.sizeof() wroks for managed objects!?
does it?

Author
2 Aug 2006 9:34 PM
Greg Young
It works for value types pretty well ;) For reference types you would need
to use unsafe code.

        struct Foo {
            public int bar;
            public int test;
            public string str;
        }
        static void Main(string[] args) {
            int foo;
            Console.WriteLine(Marshal.SizeOf(typeof(int)));
            Console.WriteLine(Marshal.SizeOf(typeof(Foo)));
        }


Cheers,

Greg
Show quote
"Leon_Amirreza" <amirreza_rahm***@yahoo.com> wrote in message
news:ehYYalntGHA.1216@TK2MSFTNGP03.phx.gbl...
>I dont think marshal.sizeof() wroks for managed objects!?
> does it?
>

AddThis Social Bookmark Button