Is it possible to remove duplicate value from datatable in C #?

I have a datatable with a MobileNo column .... My datatable has 150 rows and each row has MobileNo ... Now, how to check each MobileNo is unique, analyzing all the datarows of datatable in C #?

EDIT:

"This data type is created by reading the CSV file."

+4
source share
2 answers

Use Linq and Group MobileNo, then you will need to go through the collection and see which MobileNo has several entries, and then do whatever you want to delete, what you think is duplicated.

Edit: From Linq 101 Samples .

+3
source

Try

 DataTable.DefaultView.ToTable(bool distinct, string[] ColumnNames) 

The third overload on what you are looking for, I believe, let me know how you are doing.

  • Indicate which columns should be released in row []
  • And true false for individual entries

That way, you can simply select a subset of the data or deduplicate by setting other than true.

You will need to do something to get your dataset the way you want it, but I think this is what you need.

+1
source

Source: https://habr.com/ru/post/1309419/


All Articles