C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着

 string temp = "1,1,2,2.2,3,2";
            string[] array = temp.Split(',');
            Dictionary<string, int> dicCount = new Dictionary<string, int>();
            foreach (string s in array)
            {
                if (!dicCount.ContainsKey(s))
                    dicCount.Add(s, 1);
                else
                    dicCount[s]++;
            }

            StringBuilder sb = new StringBuilder();
            foreach (string s in dicCount.Keys)
                sb.AppendFormat("{0}个{1},", dicCount[s], s);
            Console.WriteLine(sb.ToString());

posted on 2008-08-29 10:59  王德田  阅读(207)  评论(0)    收藏  举报