Repeating data deduplication in C # datatable

Source: Internet
Author: User
        #region DataTable to Heavy///<summary>//DataTable to///</summary>/<param NA Me= "Dtsource" > Need to go to the heavy datatable</param>//<param name= "ColumnNames" > based on which column to weight </param>// <returns></returns> public static DataTable getdistincttable (DataTable dtsource, params string[] Column            Names) {DataTable distincttable = Dtsource.clone ();                                      try {if (dtsource! = null && dtSource.Rows.Count > 0) {                    DataView dv = new DataView (dtsource); distincttable = dv.                ToTable (True, columnnames); }} catch (Exception ee) {MessageBox.Show (EE.            ToString ());        } return distincttable; }///<summary>//DataTable Go heavy///</summary>//<param name= "Dtsource" > Required Go to the Heavy datatable</param>//<returns></returns> public static DataTable Getdistincttable (DataTable            Dtsource) {DataTable distincttable = null;                    try {if (dtsource! = null && dtSource.Rows.Count > 0) {                    string[] ColumnNames = Gettablecolumnname (Dtsource);                    DataView dv = new DataView (dtsource); distincttable = dv.                ToTable (True, columnnames); }} catch (Exception ee) {MessageBox.Show (EE.            ToString ());        } return distincttable;            #endregion #region Get all the column names in the table public static string[] Gettablecolumnname (DataTable DT) { string cols = String.            Empty; for (int i = 0; i < dt. Columns.count; i++) {cols + = (dt. Columns[i].            ColumnName + ","); } cols = cols. TrimEnd(','); return cols.        Split (', '); } #endregion

The above is the C # DataTable data deduplication content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.