I have the following code:
double dd;
Dictionary<string, double> dic = new Dictionary<string,double>();
bool notin = this.summedVars.TryGetValue(bacino, out dic);
if(notin == false)
this.summedVars.Add(bacino,dic);
dic.TryGetValue(id, out dd);
dic[id] = dd + d;
When I run it I get the error:
dic is set to a null reference
How do I initialize summedVars with a new Dictionary without adding values?
I suspect TryGetValue is nulling your output parameter (dic). You need a safety net after that line
e.g.
Your code would become: