C#DataTable去重操作

    #region datatable去重
        /// 
        /// datatable去重
        /// 
        /// 需要去重的datatable
        /// 依据哪些列去重
        /// 
        public static DataTable GetDistinctTable(DataTable dtSource, params string[] columnNames)
        {
            DataTable distinctTable = dtSource.Clone();
            try
            {
                if (dtSource != null && dtSource.Rows.Count > 0)
                {
                    DataView dv = new DataView(dtSource);
                    distinctTable = dv.ToTable(true, columnNames);
                }
            }
            catch (Exception e)
            {
               
            }
            return distinctTable;
        }

        /// 
        /// datatable去重
        /// 
        /// 

你可能感兴趣的:(.net,.net,c#)