Nikunj Satasiya

Nikunj Satasiya

  • 280
  • 6.1k
  • 3.5m

Get distinct records from datatable

Apr 10 2019 2:29 AM
Hello Everyone, 
 
I have a data table with the following columns and rows as I showed below.  
  1. DataTable dt = new DataTable();  
  2.            try  
  3.            {   
  4.                dt.Columns.Add("f1");  
  5.                dt.Columns.Add("f2");  
  6.                dt.Columns.Add("f3");  
  7.   
  8.                dt.Rows.Add("ABC""ATAG""");  
  9.                dt.Rows.Add("abc""atag""");  
  10.                dt.Rows.Add("abc""ATAGChild""");  
  11.   
  12.   
  13.   
  14.            }  
  15.            catch (Exception)  
  16.            {  
  17.   
  18.                throw;  
  19.            }  
I want to get distinct records from this data table (check case sensitive information) and I need the following expected output as a result in the data table.
 
Expected Output: 
 
 f1 f2
 ABC ATAG
 abc ATAGChild
 
where f1 and f2 is my column. 

Answers (5)