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++
The following would give you the size of the C# class:
Marshal.SizeOf(typeof(Myclass)); using System.Runtime.InteropServices; [StructLayout(LayoutKind.Sequential)] class Myclass { }
Remember size of a class depends on padding.