本文介绍了差异b / w通过IList和List创建实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 差异b / w在IList和List上创建实例 Ex :: Difference b/w creating the instance over IList and ListEx :: IList<Customer> objIlistCust = new List<Customer>(); List<Customer> objListCustomer = new List<Customer>(); 推荐答案 Vehicle v = new Car("Ford", "Mustang");下次使用Vehicle时,你甚至无法依赖车轮的数量,因为我可以还说: When you use the Vehicle next time, you can't even depend on the number of wheels, because I could also say:v = new Motorcycle("Yamaha", "R1"); 如果我说: If I say:Car c = new Car("Ford", "Fiesta");然后我可以取决于轮数,因为如果我试着说,编译器会抱怨: Then I can depend on the wheel count, because the compiler will complain if I try to say:c = new Motorcycle("Honda", "Fireblade");因为 知道 摩托车不是汽车。Because it knows that a Motorcycle is not a Car. 这篇关于差异b / w通过IList和List创建实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-28 06:34