Select Distinct Record from DataTable

If it is necessary to select distinct record from Data Table, then we can use following method.

        public DataTable SelectDistinct(DataTable SourceTable, string FieldName)
        {
            DataTable dt = new DataTable();
            dt = SourceTable.Clone();

            object LastValue = null;
            foreach (DataRow dr in SourceTable.Select("", FieldName))
            {
                if (LastValue == null || !(ColumnEqual(LastValue, dr[FieldName])))
                {
                    LastValue = dr[FieldName];
                    dt.ImportRow(dr);
                }
            }
            
 Continue reading