I failed to get value with string key
...
Dictionary<string, Data> dateDic = new Dictionary<string, Data>();
...
public void GetDataList(string _code, int _startDate, int _limit, out List<Data> _list)
{
_list = (from data in dateDic[_code].Values // <= System.Collections.Generic.KeyNotFoundException!!!
where data.date >= startDate
orderby data.date descending
select data).Take(_limit).ToList<Data>();
}
variable _code
is 027410
At watch window:
stockShcodeDic[_code] System.Collections.Generic.KeyNotFoundException <= Error stockShcodeDic["027410"] {Base.Data} Base.Data <= OK
The key is not present in the dictionary, you can handle it by using Dictionary.TryGetValue
or even simpler