Methods take no space in a class instance (although they do take space in the EXE file).
You can get the size of the class quote easily, but ... you don;t need to, except when you talk to unmanaged code - and the value you get is probably rather confusing.
But...
int size = Marshal.SizeOf(typeof(Myclass));
Will tell you.
Run on your class:
[StructLayout(LayoutKind.Sequential)]
class Myclass
{
int a;
float f;
public void cal() { }
public void cal2() { }
}
It will give you "8" because an int is 4 bytes, and a float is 4 bytes. But it won't tell you what you think!
If I add to your class:
[StructLayout(LayoutKind.Sequential)]
class Myclass
{
int a;
float f;
int[] array = new int[100000];
public void cal() { }
public void cal2() { }
}
How big do you think it will give you now?
The answer is "16" - the array takes 8 bytes! How? Because the array is a reference, and like all class instances all a variable contains is a reference to the actual data - and a reference on a 64 bit system is always 8 bytes, regardless of the size of the data it references.