1 ///反射数组按照要求排列 2 static void Main(string[] args) 3 { 4 Dictionary<string, int> myDictionary = SetKeyValue(); 5 int directorValue = myDictionary["公司1"]; 6 int directorValue4 = myDictionary["公司4"]; 7 int directorValue5 = myDictionary["公司5"]; 8 int directorValue8 = myDictionary["公司8"]; 9 10 //if (directorValue == 4) 11 //{ 12 for (int i = directorValue; i < directorValue4 + 1; i++) 13 { 14 Console.WriteLine(i); 15 16 } 17 Console.WriteLine("++++++++++++"); 18 for (int j = directorValue5; j < directorValue8 + 1; j++) 19 { 20 Console.WriteLine(j); 21 22 } 23 24 25 // } 26 Console.Read(); 27 } 28 private static Dictionary<string, int> SetKeyValue() 29 { 30 Dictionary<string, int> dic = new Dictionary<string, int>(); 31 dic.Add("公司1", 1); 32 dic.Add("公司2", 2); 33 dic.Add("公司3", 3); 34 dic.Add("公司4", 4); 35 dic.Add("公司5", 5); 36 dic.Add("公司6", 6); 37 dic.Add("公司7", 7); 38 dic.Add("公司8", 8); 39 dic.Add("公司9", 9); 40 return dic; 41 } 42 43 if (oldvalue == null || oldvalue.Count <= 0) 44 { 45 return true; 46 } 47 Dictionary<string, object>[] g = new Dictionary<string, object>[4]; 48 g[0] = new Dictionary<string, object>(); 49 g[1] = new Dictionary<string, object>(); 50 g[2] = new Dictionary<string, object>(); 51 g[3] = new Dictionary<string, object>(); 52 foreach (var item in oldvalue) 53 { 54 string rr = item.Key.ToString().Remove(3); 55 switch (rr) 56 { 57 case "Do1": 58 if (rdcheck1.Checked) 59 { 60 g[0].Add(item.Key, item.Value); 61 g[0] = FillControl.GetValueNew(list); 62 SetSetting(g[0],1); 63 } 64 break; 65 case "Do2": 66 if (rdcheck2.Checked) 67 { 68 g[1].Add(item.Key, item.Value); 69 g[1] = FillControl.GetValueNew(listDO2); 70 SetSetting(g[1],2); 71 } 72 break; 73 case "Do3": 74 if (rdcheck3.Checked) 75 { 76 g[2].Add(item.Key, item.Value); 77 g[2] = FillControl.GetValueNew(listDO3); 78 SetSetting(g[2], 3); 79 } 80 break; 81 case "Do4": 82 if (rd4check.Checked) 83 { 84 g[3].Add(item.Key, item.Value); 85 g[3] = FillControl.GetValueNew(listDO4); 86 SetSetting(g[3], 4); 87 } 88 break; 89 default: 90 break; 91 } 92 //return true;