我为什么想要在声明时进行隐式向上转型?我的问题源于我的教科书中的以下代码。
private readonly IList<Inventory> _cars = new ObservableCollection<Inventory>();
为什么我不只是这样做呢?
private readonly ObservableCollection<Inventory> _cars = new ObservableCollection<Inventory>();
如果我只是为了节省空间,那为什么不这样做呢?
private readonly var _cars = new ObservableCollection<Inventory>();
感谢您,