这可能是一个菜鸟问题,但无论如何我都需要问它。考虑以下两个类
public class Book{
public string Title;
public string Author;
public string ISBN;
public DateTime Published;
public string Description;
public string Genre;
public float Price
public int Pages;
public Book(){
}
}
public class BookStub{
public string Title;
public string Author;
public BookStub(){
}
}
如果我按以下方式创建每个类的实例
Book a = new Book{
Title = "Do Androids Dream of Electric Sheep?",
Author = "Philip K. Dick"
};
BookStub b = new BookStub{
Title = "Do Androids Dream of Electric Sheep?",
Author = "Philip K. Dick"
};
这两个实例是否占用相同数量的内存?还是第一个占用更多?