Do you remember the pain of removing duplicates in fetched dataset by looping, comparing etc.
it can be handled easily by using DataView.ToTable Method. The syntax is below.
DataView.ToTable(bool distinct, string columnNames)
distinct: If it’s true, the returned DataTable contains rows that have distinct values for all its columns specified in the second parameter. Default value is false.
columnNames: A string array that contains a list of the column names to be included in the returned table. The order of columns in returned table would be same as it’s appear in the array.
DataTable temp = dt.DefaultView.ToTable(true, “Region”);
DataTable temp = dt.DefaultView.ToTable(true, “Region”, “City”);
Hope you liked the post. Please share your comments.