views:

56

answers:

2

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

EDIT:

"This datatable is being created by reading a CSV file"

+3  A: 

Use Linq and Group By the MobileNo then you will need to traverse the collection and see which MobileNo's have multiple records and then do whatever you wish to remove what you deem is duplicated.

Edit: From Linq 101 Samples.

Chris Marisic
@Chris any sample were i can have a look at it...
Pandiya Chendur
+1  A: 

Try

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

the third overload on that is what your looking for I believe, let me know how you get on.

  • Specify which columns are to be deduped in the string[]
  • And a true false for distinct records

So you can either just select a subset of data out or dedupe by setting distinct to true.

You will need to do some jiggery pokery to get your dataset how you want it, but I think thats what your after.

Yoda