Deciding between interfaces and concrete classes
In this section, we will show that declaring a collection using an interface declaration rather than a concrete class declaration provides better time-based performance. We will accomplish this by benchmarking the generation of collections using an IList
interface, as well as by using a List
concrete class, so that you can see the difference in the performance of the different approaches. Follow these steps:
- In the
CH06_Collections
project, add a new folder calledConcreteVsInterface
. - In the
ConcreteVsInterface
folder, add theITax
interface:internal interface ITax { Â Â Â Â Â Â int Id { get; set; } Â Â Â Â Â Â TaxType TaxType { get; set; } Â Â Â Â Â Â TaxRate TaxRate { get; set; } Â Â Â Â Â Â decimal LowerLimit { get; set; } Â Â Â Â Â Â decimal UpperLimit { get; set; } Â Â Â Â Â Â ...