获取DataTable中一列的数据

 

#region 获取合同号
            DataRow[] arrRow = new DataRow[ds.Rows.Count];
            int w = 0;
            foreach (DataRow row in ds.Rows)
            {
                arrRow[w] = row;
                w++;
            }
            string[] ary = Array.ConvertAll(arrRow, r => r["cdono"].ToString());           
            List<string> list = new List<string>();
            ary.ToList().ForEach((s) =>
            {
                if (!string.IsNullOrEmpty(s))
                {
                    list.Add(s);
                }
            });
            ary = list.ToArray();//
            string str = string.Join("/", ary); //将ary数组中的元素转换成字符串
            #endregion

 

            #region 获取境外收货人
            string ress = "";
            DataTable de = bi.ReadDaddress(nos);//获取数据
            DataRow[] BrrRow = new DataRow[de.Rows.Count];//将数据转换成数组形式
            int q = 0;
            foreach (DataRow row in de.Rows)//将所有数据整合出来
            {
                BrrRow[q] = row;
                q++;
            }
            string[] cry = Array.ConvertAll(BrrRow, t => t["daddress"].ToString());//去掉datatable中的空数据
            string stra = string.Join("/",cry);                     
            #endregion

  

posted @ 2020-07-03 16:11  猎人7号  阅读(1787)  评论(0编辑  收藏  举报