If we had code like this:
public class Enemy
{
public int hp;
}
Then an Enemy
object would take 4 bytes in 32-bit machines, and 8 bytes in 64-bit (correct me if I'm wrong).
If we change it to something like this:
public class Enemy
{
public int hp;
public void Attack() {}
}
An Enemy
object would still take the same amount of memory as it did before, right?
The same for this:
public class Enemy
{
private int hp;
public int Hp { get { return hp; } set { hp = value; } }
}
From what I know, a property is function, but treated as a variable, right?
So if we did this:
public class Enemy
{
public int Hp { set; get; }
}
Does that mean, an Enemy
object now takes no memory space at all? That doesn't make any sense.
Or even this, for that matter:
public class Enemy
{
public void DoSomething() { }
}
Can somebody explain?