So, I'm writing a program that handles taxes. I've got a Dictionary that is set up as following:
static Dictionary<Commodity, Tuple<DateTime, double>> _TaxRates = new Dictionary<Commodity, Tuple<DateTime, double>>();
Commodity is an Enum that handles different tax areas (Food, Alcohol, Transport etc.). Now, I want to add a new tax rate, and the datetime that the tax rate was added.
So for instance, the Tax rate for Alcohol might have been 0,25% at 17:00, but at 17:25 it was 0,50% instead.
_TaxRates [commodity].Add(new Tuple<DateTime, double>(DateTime.Now, rate));
This gives me an error.
_TaxRates[commodity] = Tuple.Create(DateTime.Now, rate);
And this seems to just overwrite the old value, meaning Alcohol has only ever had one Tax rate. Any helps or tips greatly appreciated.
"Full code" below:
static Dictionary<Commodity, Tuple<DateTime, double>> _TaxRates= new Dictionary<Commodity, Tuple<DateTime, double>>();
public void SetCustomTaxRate(Commodity commodity, double rate)
{
_TaxRates[commodity].Add(new Tuple<DateTime, double>(DateTime.Now, rate));