c# list exists(contains) delegate 委托判断 元素是否在LIST中存在

static void Main(string[] args)
        {
            List<GoodsInfo> list = new List<GoodsInfo>();
            GoodsInfo g1 = new GoodsInfo();
            g1.GoodsPriceRangeName = "200~399";
            list.Add(g1);
            GoodsInfo g2 = new GoodsInfo();
            g1.GoodsPriceRangeName = "0~99";
            list.Add(g2);
            GoodsInfo g3 = new GoodsInfo();
            g3.GoodsPriceRangeName = "200-399";
            list.Add(g3);
            UltBLL ultBll = new UltBLL();
            List<Tbl_Dictionary> dictList = ultBll.GetDictInfoByDictType("GoodsPriceRange", false);
            
            foreach (GoodsInfo info in list)
            {
                if (dictList.Exists(dict => dict.DictName.Equals(info.GoodsPriceRangeName)))
                {
                    Console.Write("exists");
                }
            }
            
            Console.WriteLine("ok");
            Console.Read();
        }

上一篇:TransactionScope


下一篇:CodeForces-1076B Divisor Subtraction 找规律