zoukankan      html  css  js  c++  java
  • List.FindAll===>toArray()

     public class OrdersType
        {
            private string _OrderNum;

            public string OrderNum
            {
                get { return _OrderNum; }
                set { _OrderNum = value; }
            }
            private string _Invs_num;

            public string Invs_num
            {
                get { return _Invs_num; }
                set { _Invs_num = value; }
            }
            private string _CountryCode;

            public string CountryCode
            {
                get { return _CountryCode; }
                set { _CountryCode = value; }
            }
            private Items[] _ItemList;

            public Items[] ItemList
            {
                get { return _ItemList; }
                set { _ItemList = value; }
            }

            private GoodsInfoType[] _GoodsInfoType;

            public GoodsInfoType[] GoodsInfoType
            {
                get { return _GoodsInfoType; }
                set { _GoodsInfoType = value; }
            }
        }

    -----------------------------------------------------------------------------------------------------

      private void ListTest(List<GoodsInfoType> goods)
            {
                List<GoodsInfoType> glist = new List<GoodsInfoType>();
                string TypeId = string.Empty;
                List<string> strId = new List<string>();

                OrdersType order = new OrdersType();
                order.Invs_num = "123456";

                order.OrderNum = "MW1234848";
                order.CountryCode = "CN";


                foreach (GoodsInfoType good in goods)
                {
                    TypeId = good.GoodsTypeID1;

                    if (strId.Contains(TypeId))
                    {
                        continue;
                    }
                   
                    glist = goods.FindAll(p =>
                    {
                        if (p.GoodsTypeID1 == TypeId)
                        {
                          
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    });

                    order.GoodsInfoType = glist.ToArray();
                    strId.Add(TypeId);

                }
            }

  • 相关阅读:
    消息中间件(一)MQ详解及四大MQ比较
    SIP协议
    PAT (Basic Level) Practice 1008 数组元素循环右移问题
    LeetCode-Algorithms 1. 两数之和
    PAT (Basic Level) Practice 1040 有几个PAT
    PAT (Basic Level) Practice 1023 组个最小数
    PAT (Basic Level) Practice 1021 个位数统计
    PAT (Basic Level) Practice 1007 素数对猜想
    PAT (Basic Level) Practice 1006 换个格式输出整数
    PAT (Basic Level) Practice 1004 成绩排名
  • 原文地址:https://www.cnblogs.com/moss_tan_jun/p/2004923.html
Copyright © 2011-2022 走看看