Q:

datatable to string with unique rows

I have a datatable and I want to create a text file using this datatable.  I want that each row of the newly created text file is unique.  If there is a duplicate row, then it should add * to both rows ( duplicate rows)
I am using following code:
 Dim str As String
            For Each row As DataRow In dataTable. Rows
                str += row(1)  ' This is text data            
                str += "<br/>"
            Next

Please suggest me how to make the rows unique. 
Thanks

A:

For my example I used an array with the data, but just replace the array part with your DataTable and you should be good to go.   Basically you build a List of strings with the DataTable information then use LINQ to check and see if that data already exists once, or more than once. 
    Dim data As String() = {"A", "B", "C", "D", "E", "A", "E", "F", "G", "H", "A", "A", "B", "X", "Y", "Z"}
    Dim processedData = New List(Of String)
    Dim rowData = String. Empty
    Dim results = New StringBuilder()

    For Each row As String In data
        processedData. Add(row)
    Next

    For Each row As String In processedData
        rowData = row

        If (processedData. Where(Function(d) d = rowData).Count = 1) Then
            results. Append(rowData)
            results. Append("<br />")
        Else
            results. Append(rowData)
            results. Append("*")
            results. Append("<br />")
        End If

    Next

The results string is
A*<br />
B*<br />
C<br />
D<br />
E*<br />
A*<br />
E*<br />
F<br />
G<br />
H<br />
A*<br />
A*<br />
B*<br />
X<br />
Y<br />
Z<br />

