What is the best way to remove duplicates from a datatable?

前端 未结 12 2072
醉酒成梦
醉酒成梦 2021-01-02 13:23

I have checked the whole site and googled on the net but was unable to find a simple solution to this problem.

I have a datatable which has about 20 columns and 10K

12条回答
  •  孤独总比滥情好
    2021-01-02 14:12

    Try this

    Let us consider dtInput is your data table with duplicate records.

    I have a new DataTable dtFinal in which I want to filter the duplicate rows.

    So my code will be something like below.

    DataTable dtFinal = dtInput.DefaultView.ToTable(true, 
                               new string[ColumnCount] {"Col1Name","Col2Name","Col3Name",...,"ColnName"});
    

提交回复
热议问题