0

Initalization of dictionary

I tried to create a dictionary : public Dictionary<string, string> TipList{ get { return TipList;} set { TipList = value;} } and when I try to place anything inside the dictionary, it keeps giving a StackOverflow exception.

1st Apr 2017, 7:42 PM
John Devaule
2 Answers
+ 5
Your setter is most likely calling TipList which is calling it's setter and an infinite loops occur. Resulting in an overflow. Try initializing it like this :: private Dictionary<string, string> TEtipList; public Dictionary<string, string> TipList { get { return TEtipList; } set { TEtipList = value; } }
1st Apr 2017, 7:49 PM
Wen Qin
Wen Qin - avatar
+ 1
show us how you are using it
1st Apr 2017, 7:44 PM
Edward