C# 代码笔记_tuple元组

tuple元组:

赋值

  List<Tuple<string, int>> cc = new List<Tuple<string, int>>()
            {
                new Tuple<string, int>("满减5", 1),
                new Tuple<string, int>("满减2", 2),
                new Tuple<string, int>("满减5", 3),
                new Tuple<string, int>("满减1", 4)
            };

 取值

1  foreach (var item in cc)
2             {
3                  string ite = item.Item1;
4                 int ctNum = item.Item2;
5             }

 说明:可以当一个简单的类来用

list.ForEach的用法
 1     cac.ForEach(delegate(cfg_AttributeChild ac)//list.ForEach的用法
 2                 {
 3                     Attributec a = new Attributec();
 4                     a.ID = Convert.ToInt32(ac.ID);
 5                     a.msg = ac.Name;
 6                     a.url = ac.Url;
 7                     a.color = ac.Color;
 8                     abc.Add(a);
 9 
10                 });

 

posted @ 2015-11-24 11:12  笨笨、你好  阅读(595)  评论(0编辑  收藏  举报