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; } ...