遍历list,字典

        private void Form1_Load(object sender, EventArgs e)
        {
            List<int> ids = new List<int>();
            ids.Add(1);
            string str = "";
            Array.ForEach(ids.ToArray(), i => str += i + ",");

            Dictionary<int, int> IdAndStyle = new Dictionary<int, int>();
            IdAndStyle.Add(1, 1);
            IdAndStyle.Add(2, 2);

            foreach (KeyValuePair<int, int> kvp in IdAndStyle)
            {
                str = str + string.Format("ID = {0}, style = {1};", kvp.Key, kvp.Value);
            }
        }
原文地址:https://www.cnblogs.com/xiaochun126/p/4158152.html