日期:2014-05-17 浏览次数:20914 次
Dictionary<string, string> List = new Dictionary<string, string>(); List.Add("01", "aaa"); List.Add("0105", "aaa"); List.Add("010501", "aaa"); string str = "0105"; Dictionary<string, string> ListB = new Dictionary<string, string>(); foreach (KeyValuePair<string, string> kvp in List) { if(kvp.Key==str) continue; if (str.StartsWith(kvp.Key)) { ListB.Add(kvp.Key, kvp.Value); } } foreach (KeyValuePair<string, string> kvp in List) { if (kvp.Key == str) continue; if (kvp.Key.StartsWith(str)) { ListB.Add(kvp.Key, kvp.Value); } }
------解决方案--------------------
上面的bss代码断开了,更正一下:
class 科目树 { Dictionary<string, 科目树> 下级子科目= new Dictionary<string, 科目树>; Entity 本级别的数据; }