class Program
    {
        static void Main()
        {
            string[] s = new string[6] { "浏览器类_Firefox", "浏览器类_IE", "文字处理_Word", "文字处理_WPS", "电子地图_google地图", "电子地图_百度地图" };
            Dictionary<string, List<string>> kk = new Dictionary<string, List<string>>();
            foreach (string ss in s)
            {
                string[] arr = ss.Split(new char[] { '_' });
                if (!kk.ContainsKey(arr[0]))
                {
                    List<string> ll = new List<string>();
                    kk.Add(arr[0], ll);
                    kk[arr[0]].Add(arr[1]);
                }
                else
                {
                    kk[arr[0]].Add(arr[1]);
                }

            }
            foreach (string key in kk.Keys)
            {
                foreach (string str in kk[key])
                {
                    Console.WriteLine(str);
                }
            }
            Console.ReadLine();


           
        }
    }

运行结果:

posted on 2012-05-18 23:46  wangchao  阅读(616)  评论(0编辑  收藏  举报