not really?

G

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top