Alex Rivera | Logout

How to find the size of a class in C#

Asked 2010-02-25T05:40:30.887
27
public class A
{
  int x;
  float y;
}

How to find the size of the class in C#. Is there any operator like Sizeof(), which used to be in C++

Edit
Report

1 Answer

3

You could serialize the class into a memory stream and then get the size from there, but I wouldn't really recommend doing this unless you had to.

answered 2010-02-25T05:46:11.123

Your Answer