ItemOfReward[] AnalysisReward(ItemOfReward[] tempData) { ItemOfReward[] arry = null; Dictionary <int, ItemOfReward> dicTemp = new Dictionary <int, ItemOfReward> (); for (int i = 0; i < tempData.Length; i++) { if (dicTemp.ContainsKey(tempData [i].pid)) { dicTemp [tempData [i].pid].num++; } else { dicTemp.Add(tempData [i].pid, tempData [i]); } } arry = new ItemOfReward[dicTemp.Count]; arry.safeFree(); int count = 0; foreach (KeyValuePair <int, ItemOfReward> itor in dicTemp) { arry [count] = itor.Value; count++; } return(arry); }